Revision: 53314
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 18, 2011 21:32 by haxpor
Initial Code
#!E:/strawberry/perl/bin/perl # Handy script for using pngcrush to compress the size of png files in multiple folders $dir = "C:/Users/Haxpor/Desktop/in"; $out = "C:/Users/Haxpor/Desktop/out/"; opendir(DIR, $dir) || die("Cannot open directory"); @folders = readdir(DIR); closedir(DIR); foreach $folder (@folders) { # read in each folder opendir(SUBFOLDER, $dir."/".$folder) || print("Error reading $folder\n"); @files = readdir(SUBFOLDER); closedir(SUBFOLDER); # create dir in output folder mkdir($out."/".$folder); # process each file foreach $file (@files) { if(-f $dir."/".$folder."/".$file && $file =~ /.*.png/i) { system("pngcrush $dir/$folder/$file $out/$folder/$file"); } } print "\n"; }
Initial URL
http://haxpor.org/post/12923010987/how-to-optimize-applications-file-size-with-free-tools
Initial Description
Wrote this script to work with pngcrush command line based program on Windows system to compress several .png images in multiple folders (with only 1 level of folders, rather than that you have to repeat doing it manually). It's fast, and help doing the task at hand but it's completely clean. Please note that the code doesn't take care for all un-expected result, it just does the job in controlled environment. This script relates to my optimization on application's file size, check it out at the URL above.
Initial Title
Perl script working with pngcrush, for 1 level of folder hierarchy
Initial Tags
perl
Initial Language
Perl