General Question

XOIIO's avatar

Help with this batch script?

Asked by XOIIO (18120points) September 24th, 2011

Alright, so I am making batch script that backs up my minecraft server map every 15 minutes, and the copying line is this:

XCOPY /E /H C:\Users\%USERNAME%\Desktop\MCServer\world “C:\MCServerBackup\Backup-%DATE%\%TIME%\”

The problem is, it doesnt make a folder “sat 09\24\2011\time”, it makes folders inside of eachother. first sat 09, then 34, then 2011

how do I get it to make one folder with the date, not 3 becasue of the slashes?

Observing members: 0 Composing members: 0

3 Answers

CWOTUS's avatar

Try writing this at a DOS prompt and see if it gives you any ideas about how you can format your directory name:

echo %date:~10,4%%date:~4,2%%date:~7,2%

When I run that it gives me:
20110924 (for today)

and a simple
echo %date%
returns
Sat 09/24/2011

If your normal “Echo %date%” gives you a date that is formatted in another way (say, without the Day shown, or with the YYYY, MM, or DD values in a different arrangement, then of course you’ll need to modify the parsing of the Echo command.

I know you can do it.

XOIIO's avatar

I figured it out, using a timestamp variable that works well, now i just need to really see if 90000 milisecondswill make it back up every 15 minutes xD

dabbler's avatar

Leave the slashes, forward or backward, out of the name. Because those are used for delineating directories in just about every filesystem they will just be trouble.
Use maybe self-organizing dates in the YYYYMMDD format.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther