Shortcut to zip folder to filename with current timestamp

Posted on 2012-09-01
Last Modified: 2012-09-02

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?

Question by:zattz
    LVL 14

    Accepted Solution

    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.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
    Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
    This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
    The viewer will learn how to install the Spideroak software to backup files. Start your default browser: In the URL location bar type and press enter: When you see the spideroak site, click the “Try for free” button in the upper ri…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now