From: nobuyoshi nakada Date: 2006-01-18T14:03:36+09:00 Subject: Re: Looping through files using exec Hi, At Wed, 18 Jan 2006 13:09:23 +0900, Jason Cameron wrote in [ruby-talk:176073]: > I'm trying to do a mass encode of a large directory of media files but > I'm not having much luck. I tried to use bash but it doesn't like > filenames with spaces so now I'm trying to do it with ruby but using the > exec command it executes the first line then finishes. Here's what I've > done in the IRB. exec replaces current process with invoked command, use system instead. > Dir["*.avi"].each {|x| exec ("mencoder \"" + x + "\" -vf scale=320:240 > -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts > vbr=3:br=64 -o \"Done\\" + x + "\"") } And also bash should work if you quote names properly: opts="-vf scale=320:240 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=150 -oac mp3lame -lameopts vbr=3:br=64" for x in *.avi; do mencoder "$x" $opts -o "Done \"$x\"" done -- Nobu Nakada