Jump to content

folder wildcard method?


Recommended Posts

I'm trying to copy sub folders that may have numbers in them, from a specified Root directory and copy them to a server location.

What I want to end up with is folders from the users roaming profile specified here:
C:\Users\username\AppData\Roaming\Folder

under Folder contains
- folder 16
  -subfolder
- folder 17
  - subfolder


to a folder on the server.  So using the code below it should look something like this.
\\server1\files\data\username\2017 06 21\folder 16\subfolder

and

\\server1\files\data\username\2017 06 21\folder 17\subfolder

Nothing I have tried will grab both Folder 16 + Folder 17 folder and place them both to the destination.

 

ALL_Logs()
Func ALL_Logs()


    $SWDir1 = (@AppDataDir & '\Roaming\Folder\' & '\folder' & '??')
    $TempDir = "C:\Temp"
    $Destination = ("\\server1\files\data\" & @UserName & "\")
    $Pad = " "


    DirCopy($SWDir1, $Destination & @YEAR & $Pad & @MON & $Pad & @MDAY)
    FileCopy("c:\temp\*.log", $Destination & @YEAR & $Pad & @MON & $Pad & @MDAY)

EndFunc

 

Link to comment
Share on other sites

  • Moderators

@beato Try _FileListToArray in the help file. Something like this:

#include <Array.au3>
#include <File.au3>

Local $aFiles = _FileListToArray(@UserProfileDir & "\AppData\Roaming", "*", $FLTA_FOLDERS, True)
    _ArrayDisplay($aFiles)

You can then loop through the resultant array (modify path to suit your needs) and copy to the server.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

In your case, you'll want to do something like this once you have the array (pseudo)

#include <File.au3>
Local $aTemp
Local $aFiles = _FileListToArray(@UserProfileDir & "\AppData\Roaming", "*", $FLTA_FOLDERS, True)
    For $a = 1 To $aFiles[0]
        $aTemp = StringSplit($aFiles[$a], "\")
        DirCopy($aFiles[a], <path to server> & $aTemp[$aTemp[0]])
    Next

Please ask if you have any questions.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...