Robocopy By Date ?

Hello Gurus,
I need to backup a folder using the robocopy command. (I highly trust that command).
my problem is that I need to keep copies by DOW.
Meaning I need to have 7 folders Mon Tue Wed Thu Fri Sat and Sun.
and depending on the day ... I need to run the robocopy command like...

robocopy C:\MyDocs Z:\Tue\MyDocs /S /E /R:1 /W:1
if the day is tuesday...
Thanks a lot guys ...
Who is Participating?
dbruntonConnect With a Mentor Commented:
Look at this batch file here.

Look at response No 2.  His batch file pulls the DOW out of the system date into a variable.  He then uses xcopy it to copy it to the DOW folder.  You can adapt that easy enough for your robocopy.
Wayne BarronCommented:
OK, I do not think that you can do this with RoboCopy alone.
You will need to save your RoboCopy as a .bat file
And add a Task in [Scheduled Task]

Take a look here
This gives all the information that you need for creating the Task.
(This was written for a Shutdown, but you use the same concept for the Backup)
You will want to create different Task for the Different Days.
And you will need to create the Different .bat files for the different days as well.
Better off to name them
That way it will be easier to keep track of your scheduled task that way.

Good Luck
Wayne BarronCommented:
You will want to choose to do yours [Weekly]
And then on the next page, choose the day that you are doing.
And then just repeat this task for each day of the week.

This is the best way to do it.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

ammounpierreAuthor Commented:
I have seen many times that we could create variables in DOS... but I dont know how to...
can't we do that ? meaning create on the fly a variable that will hold "mon".."tue"...etc... ?
I am not so at ease with multiple scripts... you would have to monitor them....
Wayne BarronCommented:
If you ran each script like so
robocopy C:\MyDocs Z:\Tue\MyDocs /S /E /R:1 /W:1
And had the Task for it.
And each of the other days, then you should be fine.

What is there that needs to be monitored?

Having everything in one script.
You would have to do it like so

robocopy C:\MyDocs Z:\Mon\MyDocs /S /E /R:1 /W:1
robocopy C:\MyDocs Z:\Tue\MyDocs /S /E /R:1 /W:1
robocopy C:\MyDocs Z:\Wed\MyDocs /S /E /R:1 /W:1
robocopy C:\MyDocs Z:\Thur\MyDocs /S /E /R:1 /W:1
robocopy C:\MyDocs Z:\Fri\MyDocs /S /E /R:1 /W:1

That would be in one script.
You would have to find a way to loop through this and attach to the Day of the week.
And as for as I am aware of, I do not think that there is a way to do.

The method that I showed above, I have done on countless number of systems.
And it works flawlessly.
I even did it an atorney's office about 6 yrs ago.
And they are still using my same script that I wrote them back then.

Good Luck.
I hope you can find that DOS way, if you do.
Please post it here.

ammounpierreAuthor Commented:
Your method means that I would have to create 7 batch files monday.bat tuesday.bat etc...
right ?
and I would schedule a task to run monday.bat on mondays ...tuesday.bat on tuesdays etc...
So there would be 7 scheduled tasks to monitor...
Wayne BarronCommented:
Good on dbrunton.

ammounpierreAuthor Commented:
perfect solution ! thanks a mil !
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.