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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SCCMCanuckConnect With a Mentor Network AnalystCommented:
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
 
Lee W, MVPConnect With a Mentor Technology 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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
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 PrewConnect With a Mentor Commented:
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
All Courses

From novice to tech pro — start learning today.