From: Michael Linfield Date: 2007-09-17T16:14:37+09:00 Subject: Re: Run script against every file in a directory 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 you would add the code from jsmin.rb (that performs god knows what purpose) and have that code run against the files...for crawling a filesystem you would go about it like this: #!/usr/bin/ruby require 'find' res = [] $stdin.each_line do |file_path| res << File.size(file_path.strip) #File.size is only an example.. end #I dont know what jsmin.rb contains #so i cant say what to put there. ######### usage of this would be as follows find /etc/ -type f | ./program.rb # where /etc/ would be the directory that the # java files are in. -- Posted via http://www.ruby-forum.com/.