Solved

Need batch script to copy multiple files for Windows

Posted on 2016-09-20
4
101 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
[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 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

Independent Software Vendors: 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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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…

732 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