Solved

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

Posted on 2015-02-17
4
92 Views
Last Modified: 2015-02-18
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.
0
Comment
Question by:100questions
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
Bill Prew earned 250 total points
ID: 40615202
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
 

Author Comment

by:100questions
ID: 40615271
Thanks, however I may need to overwrite existing files with the same name, thus updating them.
Does this copy command do that?
0
 
LVL 23

Assisted Solution

by:NVIT
NVIT earned 250 total points
ID: 40615374
Add the /Y switch to Bill's solution. I.e.
COPY /y "c:\folder1\*-A*.*" "d:\folder2"
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 40615619
And as always, you can always use the /? option of a command to see what options it supports, like:

COPY /?

~bp
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Synchronize a new Active Directory domain with an existing Office 365 tenant
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now