How to Set Up a Job to Automatically Zip Files in a Folder Based on a Scheduled Task

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Zipping files automatically can save disk space when generating log files.
Image Credit: Svitlana Niedielska/iStock/Getty Images

Windows Task Scheduler enables you to run any program at a scheduled time, including recurring jobs. Further, it can launch batch files, which are text files with special instructions in them. Scheduling zip archive operations in Windows can be a little perplexing, because the component of Windows Explorer that creates zip archives from the right-mouse-click context menu is not a separate executable file. Fortunately, any one of a number of free file compression utilities that make Zip files exist, and all of them can be run via batch files through the Task Scheduler.

Advertisement

Step 1

Download and install a command-line file Zip archive tool, such as 7-Zip, Zip or WinZip (see links in Resources). Double-click the downloaded file and follow the installation wizard. All these tools have command-line versions and some also have GUI versions. You will need the command-line version for the batch file to work.

Advertisement

Video of the Day

Step 2

Start Notepad (or any other text editor of your choice).

Step 3

Enter the following line of text, or copy and paste the following into Notepad.

@echo off

Advertisement

Step 4

Enter one of the following lines as the second line in the text file you created earlier. The line you'll want to enter (or copy and paste) must match the tool you installed.

For "archive folder name," put the full Windows file system path to the folder where you want the archive to be created, and include the file name you want to use, for example: "C:\MyFiles\MyArchive" where the file "MyArchive.zip" will be created in the folder "MyFiles." For "source folder name," put the full Windows file system path to the folder containing the files you want to archive. Retain the quotation marks if your path names have spaces in the directory name or file name.

Advertisement

7-Zip: 7za a –tzip "archive folder name" "source folder name"

Advertisement

WinZip: wzzip "archive folder name" "source folder name"

Zip: zip "archive folder name" "source folder name"

Advertisement

Step 5

Click on "File," then "Save As" and name the file "FolderSaver.bat" or any other name you choose. Be sure to use the extension .bat.

Step 6

Start Task Scheduler.

Advertisement

In Windows 8, use the Search charm to find "Task Scheduler" after making sure the "Apps" icon is clicked. In Windows 7, click the "Start" menu and type "Task Scheduler" in search box. If prompted, enter your Administrator password. The Task Scheduler window opens.

Advertisement

Step 7

Click on "Actions," then "Create Basic Task." When prompted, enter the name for the task ("FolderSaver") and an optional description. Click "Next."

Step 8

Select the scheduled frequency of the task -- Daily, Weekly or Monthly, and click "Next." You can also schedule the task to run when some other non-scheduled, recurring event occurs, such as the computer restarting, or when a specific user logs in.

Advertisement

Step 9

Click on "Start a program." Click "Next," then "Browse" to navigate to the batch file, then click "Finish."

Video of the Day

Advertisement

Advertisement

references & resources