Saturday, February 9, 2013

Blogspot Markdown test

Test

Sunday, March 11, 2012

Sexy Zip Handling with 7zip in Windows

Problem: Zipped files are annoying to deal with and cause clutter
I've never been really satisfied with the way Windows utilities deal with unzipping compressed files. 98% of the time I don't want to browse a zip file, yet this is the default behavior of all decompression utilities. Almost always I'd be navigating the context menu for what I wanted, and what I wanted was usually "Extract to <filename>/ folder". No compression program had the customization I wanted and I've been on a big automation kick lately so I decided to write a batch file that would handle zip files in the way I wanted.

Desired Functionality
Upon double-clicking a compressed file:
1. Unzip file to subfolder named after zip file (i.e. Contents of squish.zip extracts to /squish/)
2. Move zip file to subfolder so it's not cluttering download folder. This also is convenient for keeping related files together.
3. Open subfolder in Explorer.

This was actually fairly easy to figure out once I learned how Windows batch file variables work. Here's the batch file, to use it, paste it into a text editor (I recommend Notepad++) and save it as unzippy.bat (make sure you're actually saving it as .bat, not .bat.txt.

"C:\Program Files\7-Zip\7z.exe" x "%1" -o* -aou
explorer.exe "%~d1%~p1%~n1"
move "%1" "%~d1%~p1\%~n1\%~n1%~x1"

Breakin' it down
Let's look at this script step by step:
"C:\Program Files\7-Zip\7z.exe" x "%1" -o* -aou
This line contains the location of your 7zip command line executable. If your 7z.exe is in a different place, edit this line. The trailing gibberish are the command line flags that make 7zip extract the files to a subfolder.
explorer.exe "%~d1%~p1%~n1"
This line opens the recently-created folder in explorer so you can work with the contents. The arguments are the batch file variables telling explorer which folder to open

move "%1" "%~d1%~p1\%~n1\%~n1%~x1"

This line uses the command line move command to relocate the zip file into the subfolder. If you don't like this particular functionality, simply edit this line out.

Using the batch file
You can drag-and-drop files onto this file, but the most convenient way is to associate the filetypes with this batch file so that every time you double-click it's all automatic.

In Windows 7, go to Default Programs in the Start Menu and select "Associate a file type or protocol with a program". Select the 7zip file extensions you want to use with this batch file and click "Change Program...". I like to put my batch file in C:\Program Files\Unzippy so that I know it's not likely to move or get messed with. Navigate to wherever you put yours and select it.

Voila! Sexy zip handling!

Tuesday, November 8, 2011

Thumb Drive USB Controller Hack

Welcome to stuff.drwicked.com, a place to catch all of my various projects into one convenient, search engine indexable place on the internets.