Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automate JavaScript files compression with YUI Compressor?

YUI Compressor does not accept wildcard parameters, so I cannot run it like this:

C:>java -jar yuicompressor.jar *.js

But I have over 500 files and would rather not have to create a batch file like this:

C:>java -jar yuicompressor.jar file1.js -o deploy\file1.js
C:>java -jar yuicompressor.jar file2.js -o deploy\file2.js
...
C:>java -jar yuicompressor.jar file500.js -o deploy\file500.js

And of course my file names are not in such uniform way.

Is there way to automate this without writing any code? :)

like image 896
z-boss Avatar asked Oct 22 '08 19:10

z-boss


1 Answers

I might go for a makefile (I think it would probably be more maintainable long term), but if you want a quick-n-dirty Windows batch command something like the following should work:

for %%a in (*.js) do @java -jar yuicompressor.jar "%%a" -o "deploy\%%a"
like image 200
Michael Burr Avatar answered Oct 04 '22 16:10

Michael Burr