Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need batch script to copy multiple files for Windows

Posted on 2016-09-20
4
Medium Priority
?
142 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 32

Expert Comment

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

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 25

Accepted Solution

by:
NVIT earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

604 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