From: Greg Hauptmann Date: 2006-12-01T07:01:43+09:00 Subject: Re: help re deleting files please? ------=_Part_35243_20972101.1164924083713 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline wow - one line - thanks heaps - gives me some pointers re where to dive into the API doco/classes - take your points thanks On 11/30/06, Hung Dao wrote: > > This smells like a homework , by the way , the best approach to Ruby is > practice by coding yourself then post the code for others to check or > optimize > Hope this piece of code helps you somehow > Dir.foreach("./") {|x| File.delete(x) if (File.size(x) <7*1024)&&( > File.size(x) > >5*1024) } > > On 11/29/06, Greg Hauptmann wrote: > > > > Hi, > > > > I have a small task which I was considering using ruby for - if anyone > has > > a > > minute and could quickly type in the ruby code (assuming its a few > lines) > > that would be fantastic. The spec is: > > > > Input > > > > - Small ruby program needs to be triggered by a windows batch file ( > > i.e. called out from within a windows batch file) > > - The batch file will be provided (from the program that kicks it off) > > with a variable containing a filename > > > > Processing > > > > - Take the filename as input > > - To search for files under a given directory (so in including > > sub-directories) and delete any files which match the conditions: > > - (size < 7kb) AND (size > 5kb) > > - file is closed (i.e. don't want to pick up a file currently > > being written to by the program which may be just starting to grow) > > - Optionally (not sure yet) - May want to limit the files to > > those which match a wildcard version of the filename which was > > provided by the batch file (e.g. if filename was " > > thisfile-v22.mpg", may want to filter on only files matching " > > thisfile*" if that makes sense. > > > > Output > > > > - No real output required, however if it was simple a log file which > > was appended to with Date/Time, FileDeleted may be nice > > > > > > Thanks in advance > > Greg > > > > > > ------=_Part_35243_20972101.1164924083713--