Looks like a script that could be useful to some. I have some suggestions for you for cleaning it up a bit.
First of all, the use of `backquotes` is discouraged these days. You should enclose your commands in $() instead:
Code:
TOP_WORKING_DIR=$(pwd)
(BTW, the pwd is also stored in its own shell variable, so you can get the same output by simply using "$PWD").
You can get the length of a variable string with ${#VAR}:
Code:
TOP_WORKING_DIR_LENGTH=${#TOP_WORKING_DIR}
You can do arithmetic inside of $(()) instead of using let:
Code:
PATH_CUT_LENGTH=$((TOP_WORKING_DIR_LENGTH+2))
You strip off everything in a string up to and including the final slash with ${VAR##*/} (this will let you avoid the above arithmetic entirely):
Code:
MAGIC_PATH=${CURRENT_WORKING_DIR##*/}
"$(basename $PWD)" will also work.
The preceding ${VAR} patterns are all examples of
parameter substitution.
Finally, in your final function, I think I'd use a case statement instead of if. It's cleaner and you only have to call the variable match once:
Code:
case "$OUTPUT_TYPE" in
avi2ogv ) avi2ogv $i ;;
wmv2ogv ) wmv2ogv $i ;;
mp42ogv ) mp42ogv $i ;;
flv2ogv ) flv2ogv $i ;;
* ) echo "Output type not recognized - please specify \"avi2ogv\", \"wmv2ogv\", \"mp42ogv\", or \"flv2ogv\"" ;;
esac
Hope these help!
Edit: I just realized we could make the case statement even shorter:
Code:
case "$OUTPUT_TYPE" in
avi2ogv | wmv2ogv | mp42ogv | flv2ogv ) $OUTPUT_TYPE $i ;;
* ) echo "Output type not recognized - please specify \"avi2ogv\", \"wmv2ogv\", \"mp42ogv\", or \"flv2ogv\"" ;;
esac