Delay Copy in Batch File

Is there a way to create a bat file to copy over several files in intervals?
Meaning copy one file then wait 60 seconds and copy over the next file?

Thanks,
LVL 1
tgarrityAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SCCMCanuckOwnerCommented:
High tgarrity, there are a number of options available, please see below:

http://www.robvanderwoude.com/wait.php

Let me know how you make out

Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lee W, MVPTechnology and Business Process AdvisorCommented:
Using the ping command in Binarymime's link:

FOR /f "tokens=*" %%a in ('dir /b') do (
   copy "%%a" "x:\path\to\copy\to"
   ping 127.0.0.1 -w 60000
)

The for command cycles through the list of files in the directory, effectively doing one at a time - the ping command causes a 60 second delay (60,000 milliseconds = 60 seconds).
0
Bill PrewCommented:
I can't help but ask, since it could affect what solutions are recommended.  What problem or effect are you trying to accomplish by pausing in between file copies?  Is it true that you don't want to copy the same file over at different times, but different files that already exist in a folder?

~bp
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

tgarrityAuthor Commented:
The scenario:

I have a folder on Server A containing 500 .xml files and 15,000 .pdf files.
The .xml files contain info on where to file .pdf files on Server B.
I need to copy one .xml file at a time  to Server B every 120 seconds.
The .pdf files can be ignored, but wanted to make everyone aware as a copy *.* will not work in this case. I'm having to copy the .xml files one at a time due to a resource issue on Server B.
If I dump all 500 .xml files onto Server B, Server B will not process the .xml files and in turn will not correctly file the .pdf files.
0
Bill PrewCommented:
Okay, so something like lee proposed should work, although you want to use an invalid IP address, not a valid one.  so something like:

FOR /f "tokens=*" %%a in ('dir /b *.xml') do (
   copy "%%a" "x:\path\to\copy\to"
   ping 1.1.1.1 -w 60000
)

~bp
0
t0t0Commented:
Okay, to solve this issue, forget about delays etc... that's nonsense

Your code should consist of a single batch file which reads the information from each xml file one-at-a-time and then process pdf files accordingly.

From a top-level design viewpoint, the code (in pseudocode) shoulf look something like this:


FOR all XML files in the XML folder/s
   get the next XML file
   process it's data
   file PDF files accroding to data
END


It's as simple as that.

I'm busy right now writing code elsewhere however, when I am through with that I will return here to assist you further if in the meantime another expert has not already done so.
   
0
tgarrityAuthor Commented:
I ended up using the following script:

FOR /f "tokens=*" %%a in ('dir /b *.xml') do (
   copy "%%a" "Z:\"
   ping 1.1.1.1 -n 90
)

pause

Thanks for all the help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.