Solved

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

Posted on 2015-02-17
4
101 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 56

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 25

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 56

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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