Linux.com

spaces in filenames

Posted by: Anonymous Coward on November 02, 2006 11:47 AM
Hi, made some little changes to get the script working with filnames containing spaces.



(The original code works as well but saves files containing spaces in name as ".avi" so the file will be overwritten when using a list of filenames to convert and in the end just you'll just get the last file)



May I'll also make an -dir option wich allows to convert all files in a specified directory.



So here the changed version:
<tt>#!/bin/sh

if [ -z "$1" ]; then
  echo "Usage: $0 {-divx|-xvid} list_of_flv_files"
  exit 1
fi

# video encoding bit rate
V_BITRATE=1000

while [ "$1" ]; do
  case "$1" in
    -divx)
      MENC_OPTS="-ovc lavc -lavcopts \
        vcodec=mpeg4:vbitrate=$V_BITRATE:mbd=2:v4mv:autoa<nobr>s<wbr></nobr> pect"
     <nobr> <wbr></nobr>;;
    -xvid)
      MENC_OPTS="-ovc xvid -xvidencopts bitrate=$V_BITRATE:autoaspect"
     <nobr> <wbr></nobr>;;
    *)
      if file "$1" | grep -q "Macromedia Flash Video"; then
           BasName=`basename "$1"<nobr> <wbr></nobr>.flv`
           NewName=`echo "$BasName" | tr ' ' '_'`
           mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame \
             -lameopts fast:preset=standard -o \
             "${NewName}.avi"
           mv ${NewName}.avi "${BasName}.avi"
      else
        echo "$1 is not Flash Video. Skipping"
      fi
     <nobr> <wbr></nobr>;;
  esac
  shift
done</tt>

#

Return to How to convert YouTube videos to DivX or XviD