Jump to content

Copy file by name


 Share

Recommended Posts

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.

Link to comment
Share on other sites

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!

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