Solved

Need batch script to copy multiple files for Windows

Posted on 2016-09-20
4
108 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 29

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] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
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 …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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