Home » Questions » Computers [ Ask a new question ]

What's the easiest way to zip/rar/arj a directory with a timestamp for a name?

What's the easiest way to zip/rar/arj a directory with a timestamp for a name?

What would be the easiest way of zipping/raring/arjing a directory with a timestamp for a name?

Asked by: Guest | Views: 356
Total answers/comments: 1
Guest [Entry]

"On the console you can do

rar a -r ""backup-%DATE%.rar"" ""C:\Path\To\Directory""

If you also want the the time in the archive name, things get more complicated since %TIME% usually contains characters illegal for a file name (like :). To remove the colons form %TIME%, you could use some wired for-loop syntax:

FOR /F ""tokens=1,2,3 delims=:"" %i IN (""%TIME%"") DO (
rar a -r ""backup-%DATE%-%i.%j.%k.rar"" ""C:\Path\To\Directory""
)

(See for /? for details on what this does.)"