beato Posted June 21, 2017 Posted June 21, 2017 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
Moderators JLogan3o13 Posted June 21, 2017 Moderators Posted June 21, 2017 @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!
beato Posted June 21, 2017 Author Posted June 21, 2017 Thanks, I had come across the _filelisttoarry, but not very good at arrays/passing that data on. I'll see what I can do.
Moderators JLogan3o13 Posted June 21, 2017 Moderators Posted June 21, 2017 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. beato 1 "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!
beato Posted June 21, 2017 Author Posted June 21, 2017 Thank you , that works great. I'm working through it though to understand all of the logic/syntax
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now