Sunday, September 25, 2016

How to Automatically Unzip Files Downloaded from Chrome on Windows

macOS has a nice feature where it can automatically unzip “safe” files after downloading. I was looking for a way to do the same thing on Windows and couldn’t find a nice tutorial using free or open source software, so I decided to create my own. I should say that this process could be a security concern if you manage to download a file that unzips into a virus, but I decided that the convenience is worth the possible risk.

The first step is to follow this tutorial on to set up 7-Zip and add it to your Environment Variables. If you’re on Windows 10, the user interface is a little different (and much nicer in my opinion) but follows essentially the same steps.

Adding 7-Zip to Environment Variables

Next, you can follow their tutorial on creating a batch file to extract zip files. There’s a couple options such as moving the zip once its extracted or even deleting it if you want. I download my files directly to the Desktop, so I chose to extract them there and then move the zip file to my Downloads folder afterwards. Here’s my batch file for reference: (note: REM is how to create a comment in Windows batch files)

REM unzip any .zip files saved to the desktop
7z x -oC:\Users\Dillon\Desktop\* C:\Users\Dillon\Desktop\*.zip
REM then move the .zip directory to the downloads folder
move C:\Users\Dillon\Desktop\*.zip C:\Users\Dillon\Downloads

Here is where we branch off from their tutorial. They use software called Directory Monitor, and it may have been free when the tutorial was released, but is now paid software. I chose to use File Watcher Utilities instead because it is free and open source. Download that and put it somewhere that you won’t lose it (I chose to place it in C:\Program Files\). I also placed my unzip batch file into that folder. Now we can create the file watcher daemon.

1. Click on Edit, New…

2. Name the daemon, add the directory where Chrome downloads your files, and enable the daemon.

3. Select the file system events to watch. I chose “changed”, “created”, and “renamed”. Chrome downloads are actually saved with a .crdownload file extension until they are fully downloaded, so the “renamed” watcher is actually what triggers the daemon. I kept the others checked in case I want to manually move a file to the Desktop to unzip.

4. Add a “*.zip” filter so only zip files trigger the daemon, and not every file change that takes place on the Desktop.

5. Add your batch file to the process executable. Note that you will have to change the explorer window to display all files to see the .bat file extension. Also enter a working directory for intermediate files.

6. I chose to “Create no window” so that the batch file popup does not disturb my work.

7. Hit OK to save the daemon and then select Start to begin the daemon.
8. Download a .zip file from Chrome and ensure that everything works as you expect. Check out the Log messages tab to debug if it is not working satisfactorily.
9. Finally, in Tools, Options…, select “Start all enabled file watchers at startup” if you want that feature.

And that’s it! Hope this comes in handy and saves you some time. Please recommend this article below if it helps you and feel free to share with your friends!

Cross-posted on Medium.

No comments:

Post a Comment