Solved

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

Posted on 2015-02-17
4
94 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 52

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 52

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
A procedure for exporting installed hotfix details of remote computers using powershell
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

25 Experts available now in Live!

Get 1:1 Help Now