帮助。我尝试过的一切都失败了。我正在尝试修复我的视频收藏,其中很多在名称/等中有空格我想对它们进行转码,我已经编写了下面的脚本,但它失败了。我用于测试的 2 个文件名是“13 Eerie (2013).avi”和“Ace.Ventura.When.Nature.Calls.1995.720p.WEB-DL.x264-mSD.mkv”
我已经尝试了几件事,从在 find 上使用 print0 到破坏 IFS。任何援助将不胜感激。由于某些原因,当前版本将 e 字符上的所有内容分开
转换.sh
#!/bin/sh
OUTDIR="./done/"
LOGDIR="./logs/"
BACKUPDIR="./backup/"
# deal with spaces
SAVEIFS=$IFS
IFS=$(echo -en "\n")
# pull all files except MP4 or scripts in the CURRENT DIR only
for FULLFILENAME in `find . -maxdepth 1 -type f -not -iname "*.sh" -not -iname "*.mp4" -print`
do
# extract the file extension
filename=$(basename "$FULLFILENAME")
ext="${filename##*.}"
filename="${filename%.*}"
# use handbrake to convert to x264
HandBrakeCLI -i "$FULLFILENAME" -o "$OUTDIR$filename.mp4" -e x264 -q 22 -r 29.97 -B 64 -O 2>$LOGDIR$filename.log
# move the original file to a backup
mv "$FULLFILENAME" $BACKUPDIR
done
#restore the field separator
IFS=$SAVEIFS