Quote:
Originally Posted by Bonken
Edit: Thanks the script worked, but it only converted one file.
|
This is because there must be only one avi file in the
current directory, the other ones are in subfolders.
In that case you must recurse thru all the directories
###modified script
#!/bin/sh
TOP=full_path_to_the_directory_just_above_the_AVI_directory
#replace avi by the actual name of your avi directory
AVI=$TOP/avi
FLV=$TOP/flv
find $AVI/* | while read f
do
if [ -d $f ]; then
continue
fi
cmd="echo $f | sed 's?^$AVI?$FLV?' | sed 's?\.avi?.flv?'"
g="$(eval $cmd)"
d=${g%/*}
ext=${g##*.}
if [ "$ext" == "avi" ]; then
input="$f"
output="$g"
echo "mkdir -p $d"
# mkdir -p $d
echo "ffmpeg -i "$input" -y -f flv -ar 44100 -ab 64 -ac 1 -acodec mp3 \"$output\""
# ffmpeg -i "$input" -y -f flv -ar 44100 -ab 64 -ac 1 -acodec mp3 "$output"
fi
done
##########end of script ################
1. remove the echo lines after you tested it
(and then remove the '#' comment below those lines)
2. I'll comment some lines
find $AVI/* | while read f
this will look for every file/folder in the $AVI path, and
store it in the variable f
g="$(eval $cmd)"
this will form the output full path name
d=${g%/*}
this will form the full path to the directory where the output file
must reside
mkdir -p $d
create the target directory if it doesn't already exist
now the conversion command is called if $f is a file and
its extension is avi
the output is written in a similar folder/subfolder and same name
but different extension (flv instead of avi)