编辑:最后调用的 fixnames.sh 可能会产生错误(特别是第 2 行):
#/bin/bash
for x in *\'*;
do
y=$(echo "$x"| sed y/\'\,/__/)
mv "$x" "$y"
done
问题行是最后的 mv 命令
mv $OUTDIR/$OLD $OUTDIR/$NEW
它会出现以下错误:
mv '*\* [something about unable to stat this]
这个脚本是我从http://www.mythtv.org/wiki/Removing_Commercials和其他一些地方发布的脚本定制的。mv 的目标是,iirc,清理 tmp 目录(删除我笨拙地用来重命名文件的符号链接)。我有点不清楚该 mv 行和之前的 2 行中发生了什么,这显然导致脚本无法干净地完成。感谢您的任何意见。
#!/bin/sh
VIDEODIR=$1
FILENAME=$2
CHANID=$3
STARTTIME=$4
# MythTV Install Prefix
INSTALLPREFIX="/usr/bin"
USRLOCALPREFIX="/usr/local/bin"
HOMEDIR="/home/xxx"
OUTDIR="/home/xxx/trans-out"
TMPDIR="/home/xxx/trans-out/tmp"
if [ ! -d $TMPDIR ]; then mkdir $TMPDIR; fi
rm -f $TMPDIR/*
# Sanity checking, to make sure everything is in order.
if [ -z "$VIDEODIR" -o -z "$FILENAME" -o -z "$CHANID" -o -z "$STARTTIME" ]; then
echo "Usage: $0 <VideoDirectory> <FileName> <CHANID> <STARTTIME>"
exit 5
fi
if [ ! -f "$VIDEODIR/$FILENAME" ]; then
echo "File does not exist: $VIDEODIR/$FILENAME"
exit 6
fi
# The meat of the script. Flag commercials, copy the flagged commercials to
# the cutlist, and transcode the video to remove the commercials from the
# file.
$INSTALLPREFIX/mythtranscode --chanid $CHANID --starttime $STARTTIME --mpeg2 --honorcutlist --showprogress -o $OUTDIR/$FILENAME.tmp
ERROR=$?
if [ $ERROR -ne 0 ]; then
echo "Transcoding failed for ${FILENAME} with error $ERROR"
exit $ERROR
fi
# use mythlink script to extract program information from database and make link in tmp subfolder for renaming of transcoded version.
$USRLOCALPREFIX/mythlink.pl --link $TMPDIR --chanid $CHANID --starttime $STARTTIME --underscores --separator _ --format %T_%oY%om%od_%S
# remove the map file since we are transcoding
rm -f $OUTDIR/$FILENAME.tmp.map
# set variables for newfilename-link and oldfilename-transcoded file and then to rename transcoded with link name
NEW=$(ls $TMPDIR)
OLD=$(ls $OUTDIR | grep -i "mpg.tmp" | awk '{ print $1; }')
mv $OUTDIR/$OLD $OUTDIR/$NEW
# remove commas and apostraphies
cd $OUTDIR && $USRLOCALPREFIX/fixnames.sh