Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple question, but I don't remember the batch syntax very well. If I want to create a batch file that transfers all the files in Folder A to Folder B every 20 minutes, what does the batch file need to look like?

I think something like this:

-script that search if there are files -
-script that moves the files to the folder B-
sleep(x seconds)
go to 1;

Thanks all

share|improve this question
What operating system are you on? Are you talking about a .bat file on Windows that will perform this? – Raystafarian Mar 2 '12 at 18:53

I would suggest writing a batch file to move those files without any sleeps or gotos, then set up a scheduled task to run that batch file every 20 minutes. Although this doesn't directly answer your question, I think it's what you want to achieve from asking your question.

If you did want to use your method, try:

commands here...
GOTO Label1
share|improve this answer
I can try also the schedule, but i don't know really how it work, i have present the scheduler but don't know how to use or configue. With Label1 what execute? and what commands i need to write? Thanks – Synthoras Mar 2 '12 at 11:54

I'm assuming you are using XP or up.

Using the Task scheduler makes more sense here. It will use less CPU.

schtasks /create /sc minute /mo 20 /tn "Copy file X per 20min" /tr "path to your batchfile" /k

share|improve this answer

Ok, first of all, I didn't know there was a Sleep command...(Just went to search it)

However, what I use last time was Timeout as it count down in Seconds instead of minutes, so you might give it a try! Here is the syntax:

Timeout /t 1200
Goto loop
  • The number 1200 is the time in seconds (60*20=1200)
  • The /t is necessary
  • After the whole line Timeout /t 1200, you can add a optional /nobreak so that it will strictly wait till 1200 seconds before proceeding and will not be affected by key presses in the CMD window.
  • And finally, after the whole line( With or without /nobreak, the timer will start counting down in your Batch window, you can choose not to let it appear and let it count in background by adding >nul

That's about it, so try timeout

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.