From: Jason Cameron Date: 2006-01-18T14:03:03+09:00 Subject: Re: Looping through files using exec vrtwo lastname wrote: > You said bash... > > Does "Done" represent a directory? and.. does Done\#{filename} work > with this option? I would have thought that in *nix, it would be > Done/#{filename} > > Not exactly sure what this app is supposed to do but the loop looks ok.. > > irb(main):004:0> puts "mencoder \"" + x + "\" -vf scale=320:240 -ovc > lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts > vbr=3:br=64 -o \"Done\\" + x + "\"" > mencoder "pron.avi" -vf scale=320:240 -ovc lavc -lavcopts > vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64 -o > "Done\pron.avi" If I replace exec with puts it lists the commands fine. My problem is that when I use exec it runs the first command fine then exits ignoring all the other files. For example if I have a directory that has the files: bar1.avi bar2.avi bar3.avi and I use the following in IRB: Dir["*.avi"].each {|x| puts ("mencoder \"" + x + "\" -vf scale=320:240 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64 -o \"Done\\" + x + "\"") } I get the following output: mencoder "\bar1.avi" -vf scale=320:240 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64 -o "Done\bar1.avi" mencoder "\bar2.avi" -vf scale=320:240 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64 -o "Done\bar2.avi" mencoder "\bar3.avi" -vf scale=320:240 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64 -o "Done\bar3.avi" but if I do: Dir["*.avi"].each {|x| puts ("mencoder \"" + x + "\" -vf scale=320:240 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64 -o \"Done\\" + x + "\"") } It will only execute: mencoder "\bar1.avi" -vf scale=320:240 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64 -o "Done\bar1.avi" -- Posted via http://www.ruby-forum.com/.