• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1040
  • Last Modified:

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
0
zattz
Asked:
zattz
1 Solution
 
quizwedgeCommented:
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now