Jump to content
Sign in to follow this  
stg68

Copy file by name

Recommended Posts

stg68

I would like to copy all files from one directory to another where file name starts with number (0-9).

Your help will be appreciated.

Regards

Share this post


Link to post
Share on other sites
DaRam

I would like to copy all files from one directory to another where file name starts with number (0-9).

Your help will be appreciated.

Regards

For $i = 0 to 9
    If FileExists("C:\" & $i & "*.*") Then
       FileCopy("C:\" & $i & "*.*", "D:\mydir\*.*")
    EndIf
Next

Replace C:\ with source Drive and Path, D:\mydir\ with Target Drive and Path.

Share this post


Link to post
Share on other sites
stg68

For $i = 0 to 9
    If FileExists("C:\" & $i & "*.*") Then
       FileCopy("C:\" & $i & "*.*", "D:\mydir\*.*")
    EndIf
Next

Replace C:\ with source Drive and Path, D:\mydir\ with Target Drive and Path.

Cool! Thank you a lot!

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  

×