Solved

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

Posted on 2015-02-17
4
100 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 54

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 24

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 54

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will help you understand what HashTables are and how to use them in PowerShell.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

751 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