Run PNGOUT on all PNG Files in a Folder

Here is a quick registry hack to add a new entry “Run PNGOUT on Folder” to your context menu. It will iterate through all the files in the directory, and run PNGOUT on every PNG file it finds. It will leave all the other files alone, so you don’t have to worry about errors, or data corruption. Simply copy the code below:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT]
@="Run PNGOUT on Folder"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT\command]
@="cmd.exe /c \"TITLE Running PNGOUT on %1 && FOR /r \"%1\" %%f IN (*.png) DO pngout \"%%f\" \""

Paste it into notepad, save it as a .reg file, and run it by double clicking it. It should install the extension for you. This will come useful if you need to optimize a whole folder of files at once. The script should recourse into sub folders, so you can run it on the root of your website, then go to sleep and wake up to a fully PNG optimized web page.

If you want to remove this context menu item it at some point, repeat the whole procedure with:

Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT\command]

Please note that this script assumes that PNGOUT.exe is somewhere in your path. If it’s not, make sure you put it in a folder within your path to ensure the script works.

Update 07/26/2007 09:58:20 PM

Just for the sake of completion, Scott Hanselman created very similar registry hack, allowing you to run PNGOUT on a single file.

[tags]pngout, png, png compression, png size reduction, registry, hax[/tags]

This entry was posted in sysadmin notes and tagged , , . Bookmark the permalink.



One Response to Run PNGOUT on all PNG Files in a Folder

  1. Ivan NEW ZEALAND Mozilla Firefox Windows says:

    Just wanted to say thanks a lot for this post – whenever I set up a computer that I use to make graphics for the web, one of the first things I do is download PNGOUT and come to this website to get this great fix :)

    Reply  |  Quote

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>