Solved

Need batch script to copy multiple files for Windows

Posted on 2016-09-20
4
83 Views
Last Modified: 2016-09-22
I want to copy the following files below with a batch script that I can schedule using task scheduler. I want to replace with new files with every copy. If possible, even if the file is locked. Xcopy? Any good batch scripts?

ARCPMA01.CDX
ARCPMA01.DBF
ARCUST01.CDX
ARCUST01.DBF
arcust01.FPT
ARIALT01.CDX
ARIALT01.DBF
ARIALT01.FPT
ARIDET01.CDX
ARIDET01.DBF
ARIDET01.FPT
ARINVT01.CDX
ARINVT01.DBF
ARINVT01.FPT
ARINVT02.CDX
ARINVT02.DBF
ARINVT02.FPT
POMAST01.CDX
POMAST01.DBF
POMAST01.FPT
POTRAN01.CDX
POTRAN01.DBF
POTRAN01.FPT
POYMST01.CDX
POYMST01.DBF
POYMST01.FPT
POYTRN01.CDX
POYTRN01.DBF
POYTRN01.FPT
WOLABO01.CDX
WOLABO01.DBF
WOMAST01.CDX
womast01.DBF
womast01.FPT
WOTRAN01.CDX
WOTRAN01.DBF
wotran01.FPT
WOYTRN01.CDX
WOYTRN01.DBF
woytrn01.FPT
0
Comment
Question by:maximus1974
  • 2
4 Comments
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41807879
Do you know power shell commands ? It is one of good option.
0
 
LVL 24

Expert Comment

by:NVIT
ID: 41807908
Do you want to copy just those files listed? Or, do you want all the files of a certain folder?

To copy just those files listed...
- Make a file named FilesToCopy.txt. In it, put each filename you listed on a separate line
- Make this file CopyFiles.bat with this code.
- Adjust SourceDir, and TargetDir value per your need:

set SourceDir=c:\sourcefolder
set TargetDir=c:\targetfolder
for /f "tokens=*" %%a in ('type "C:\local\FilesToCopy.txt"') do (
  echo xcopy /z /y "%%a" "%TargetDir%"
)

Open in new window


- When you have confirmed that it works manually, you can add a scheduled task Action that runs CopyFiles.bat
0
 

Author Comment

by:maximus1974
ID: 41808882
Thank you but it is not working. I attached a screenshot. I run the batch from a command prompt but it is not copying the files.
Capture.PNG
0
 
LVL 24

Accepted Solution

by:
NVIT earned 500 total points
ID: 41809092
Apologies.  I forgot to mention it wa in test mode. Try this instead....

set SourceDir=w:\
set TargetDir=g:\qav
for /f "tokens=*" %%a in ('type "C:\batch\FilesToCopy.txt"') do (
  echo xcopy /z /y "%SourceDir%%%a" "%TargetDir%"
)

Open in new window

0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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