Jump to content

Save File from Folder With Variable Name


Recommended Posts

Hi guys ,

i need to save files from folder with variable name .

For example:

.

from c:\mydirectory\myfolder_Tom\*.* to c:\windows\destination folder

the problem is folder name (myfolder_Tom) , becouse i can have same folder but with different name

from c:\mydirectory\myfolder_Jerry\*.* to c:\windows\destination folder

My question is , could i make a little script to copy all in this way ?

from c:\mydirectory\myfolder_*\*.* to c:\windows\destination folder

Please , help me with link , code or other suggestion

Thank so much for your collaboration

Regards

Anyb

Link to comment
Share on other sites

Heres a little start, that might help you begin.

Global $aUsers[2] = ["myfolder_Tom", "myfolder_Jerry"] ; Array of user folders

_MyCopyFunction($aUsers)

Func _MyCopyFunction($aNames)
    Local $sPath = "c:\mydirectory\" ; Your path
    For $i = 0 To UBound($aNames) -1 ; 0 to amount of user folders in array
        _DoSomethingWith($sPath & $aNames[$i]) ; process your folder
    Next
EndFunc

Func _DoSomethingWith($sUserpath)
    ;code
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Another way, using a wildcard to search for the folders:

#include <File.au3>

$sSrc = "c:mydirectory"
$sSearch = "myfolder_*"
$sDest = "c:\windows\destination"
$aDirs = _FileListToArray($sSrc, $sSearch, 2) ; 2 = Folders only
For $n = 1 To $aDirs[0]
    DirCreate($sDest & "\" & $aDirs[$n])
    DirCopy($sSrc & "\" & $aDirs[$n], $sDest & "\" & $aDirs[$n], 1)
Next

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...