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.
- # 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/";
- @folders = readdir(DIR);
- foreach $folder (@folders)
- # read in each folder
- @files = readdir(SUBFOLDER);
- # create dir in output 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";
You need to login to post a comment.