Shortcut to zip folder to filename with current timestamp


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?

Who is Participating?
quizwedgeConnect With a Mentor Commented:
First, download 7-Zip from

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

You'll then want to use the following code to rename

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

Open in new window

See for the format of the date and time. Date will be variables d through g. Time variables will be h, i, and j.
zattzAuthor Commented:
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.