From: Terry Poulin Date: 2007-09-17T02:07:19+09:00 Subject: Re: Run script against every file in a directory Mohit Sindhwani wrote: > Chris Gallagher wrote: >> Hi, >> >> I'm currently tryin to implement a ruby script which will run through a >> directory of javascript files and run jsmin.rb against each of them as a >> part of my build script. im running into a number of silly issues so im >> just wondering if theres anyone out there thats done this kind of thing? >> >> Cheers, >> >> Chris >> Well in a Unix Shell this would probably do it, as would a for loop with a bit of change: find /directory -name "*.js" -type f -exec jsmin.rb {} \; In Ruby, I would suggest using ether the Find class or the Filescan gem. You can use it to recurse through the directory and then have the ruby script execute jsmin.rb with the file name as an argument. TerryP. -- Email and shopping with the feelgood factor! 55% of income to good causes. http://www.ippimail.com