How to automatically select files that contain specific data in the name and copy using Robocopy?

Using batch and Powershell, I would like the script to look in a specific folder, ie c:\folder1\...  if it sees a -A in the name of the file, then it need to copy all the files which have -A into a new folder, ie d:\folder2\
It needs to overwrite any files that it already finds in d:\folder2\.
A sample of the file could be 12345 A 8x10.abb
Preferably using robocopy for the actualy copying and overwriting of the files.

Alternatively, the same scenario above, however searching for files ending with -A.abb, and copying those files into the d:\folder2\.   A sample of this type of file could be 12345 8x10-A.abb.
100questionsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Bill PrewConnect With a Mentor Commented:
You really don't need anything as powerful or fancy as Powershell, or ROBOCOPY.  You should be able to handle you two needs with a basic COPY command like:

COPY "c:\folder1\*-A*.*" "d:\folder2"

and

COPY "c:\folder1\*-A.abb" "d:\folder2"

~bp
0
 
100questionsAuthor Commented:
Thanks, however I may need to overwrite existing files with the same name, thus updating them.
Does this copy command do that?
0
 
NVITConnect With a Mentor Commented:
Add the /Y switch to Bill's solution. I.e.
COPY /y "c:\folder1\*-A*.*" "d:\folder2"
0
 
Bill PrewCommented:
And as always, you can always use the /? option of a command to see what options it supports, like:

COPY /?

~bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.