the old spaces in file names thingy in shell scripts
Bill Jonas
bill at billjonas.com
Thu Oct 11 14:53:16 MST 2007
On Thu, Oct 11, 2007 at 09:23:16AM -0700, Craig White wrote:
> #!/bin/sh
> #
> BASE="/home/storage/users/craig/Desktop/dw"
> IN="in"
> OUT="out"
> for f in *.flv; do
> MP4=`basename "$f" .flv`.mp4
> ffmpeg -i "$f" "$MP4"
> mv "$f" "$BASE/$IN"
> mv "$MP4" "$BASE/$OUT"
> done
To use a bash-specific feature, you could rewrite it as follows:
#!/bin/bash
BASE="/home/storage/users/craig/Desktop/dw"
IN="in"
OUT="out"
for f in *.flv; do
ffmpeg -i "$f" "${f//flv/mp4}"
mv "$f" "$BASE/$IN"
mv "${f//flv/mp4}" "$BASE/$OUT"
done
It saves a process or two each time through the loop at the expense of
some portability. See the "Parameter Expansion" section in bash(1) for
more details.
--
Bill Jonas * bill at billjonas.com * http://www.billjonas.com/
"It's a dangerous business, Frodo, going out your front door. You step
into the Road, and if you don't keep your feet, there is no knowing
where you might be swept off to." -- Bilbo Baggins
More information about the PLUG-discuss
mailing list