Jump to content
Sign in to follow this  

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



Share this post

Link to post
Share on other sites

Heres a little start, that might help you begin.

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


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

Func _DoSomethingWith($sUserpath)

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

Monkey's are, like, natures humans.

Share this post

Link to post
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)


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

Share this post

Link to post
Share on other sites

Good morning guys .

all work fine....thank for that !!

and if possible last help

how to rename this folder ( with variable name ) in to other name


from c:\windows\Myfolder x to c:\windows\duke

x is the variable

Thank so much


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...