Sign in to follow this  
Followers 0
beato

folder wildcard method?

5 posts in this topic

#1 ·  Posted

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

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

@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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thanks, I had come across the _filelisttoarry, but not very good at arrays/passing that data on.  I'll see what I can do.

Share this post


Link to post
Share on other sites

#4 ·  Posted

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.

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted

Thank you , that works great.  I'm working through it though to understand all of the logic/syntax

Share this post


Link to post
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
Sign in to follow this  
Followers 0