The [other day] I covered how to use YUI Compressor like any old command line for those of us not overly used to working with java classes. This is great for working with single files but I wanted something to iterate through a directory and compress all files of a certain type. So here is a little command line tool for doing that. (Refer to the [previous post][other day] for more background info)
Save this file as ‘yuibatch’ in /usr/local/bin/java with chmod a+x. The script assumes that both `$PATH` and `$CLASSPATH` contain `/usr/local/bin/java` and also assumes that you have yuicompressor.jar installed in `/usr/local/bin/java`. Though you can forgo most of those assumptions and use the alternative alias pointed at where ever your `yuicompressor.jar` exists.
To use it, navigate to the folder in question and type the command `yuibatch [type]` where type is the file type you wish to compress, either `css` or `js`. For example:
[other day]: http://adam.merrifield.ca/2012/05/04/simplified-cli-use-of-yui-compressor/ “Simplified CLI use of YUO Compressor”