Shortcut to zip folder to filename with current timestamp

Hi

I am looking for something I can execute from a windows shortcut or batch file to zip the contents of a folder to a compressed filename that includes the current date and time. Does anybody know of something?

Thanks
zattzAsked:
Who is Participating?
 
quizwedgeConnect With a Mentor Commented:
First, download 7-Zip from 7-zip.org.

To zip the contents of the file, use the following line in your batch file:
7z a -tzip archive.zip C:\MyDirectory

You'll then want to use the following code to rename archive.zip

set var="%date% %time%"
for /f "tokens=1-7 delims=:/ " %%d in ("%var%") do rename "archive.zip" %%e-%%f-%%g-%%h-%%i.txt

Open in new window

See http://www.computerhope.com/issues/ch000987.htm for the format of the date and time. Date will be variables d through g. Time variables will be h, i, and j.
0
 
zattzAuthor Commented:
Thanks!
0
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.