Sign in to follow this  
Followers 0
anybastard

Save File from Folder With Variable Name

5 posts in this topic

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

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

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

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)
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

Share this post


Link to post
Share on other sites

Hi guys ,

thanks for your prompt help

Today morning i will try your solution and share with us my feedback

Regards

AnyB

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

example

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

x is the variable

Thank so much

AnyB

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