From: "ara.t.howard" Date: 2007-09-29T06:45:31+09:00 Subject: Re: is there to invoke 'previous' in Find? (or refresh the current path?) On Sep 27, 2007, at 4:10 PM, dtown22@gmail.com wrote: > myFile.txt > Mod-myFile.txt > > Basically, what i want to do is traverse down the hierarchy, when i > reach a set of files, call the app on that directory, then delete the > original, and rename the new file so that the "Mod-" is removed. > Unfortunately, the Find function doesnt see the newly created file, > and thus i cant delete & rename. My code looks something like this: > > Find.find(startingDir) do |path| > if File.directory?(path) > next > else > system("myapp #{path}") > puts path > if File.basename(path) =~ /^Mod-/ > if File.exists?(path.sub('Mod-', '')) > File.delete(path.sub('Mod-', '')) > end > File.rename(path, path.sub('Mod-', '')) > end > end > end this makes no sense at all - you *know* that the file is created - you don't *care* if find sees it. all you need to do is require 'fileutils' Dir.glob('**/**') do |src| next if test ?d, src dst = "Mod-#{ src }" cmd = "app #{ src }" system cmd abort "<#{ cmd }> failed with <#{ $?.inspect }>" unless $?.exitstatus.zero? and test ?e, dst FileUtils.rm_f src FileUtils.mv dst, src end or am i missing something here? cheers. a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama