EDIT: the fixnames.sh called at the end is probably generating the error (particularly line 2):
#/bin/bash
for x in *\'*;
do
y=$(echo "$x"| sed y/\'\,/__/)
mv "$x" "$y"
done
The problem line is the mv command at the end
mv $OUTDIR/$OLD $OUTDIR/$NEW
It errors with something like:
mv '*\* [something about unable to stat this]
This script was something I customized from one that had been posted here http://www.mythtv.org/wiki/Removing_Commercials and some other places. The goal of the mv was, iirc, to clean up the tmp directory (removing a symbolic link that I clunkily used to do a rename of the file). I’m a little unclear on what is happening in that mv line and the 2 lines prior that is apparently causing the script not to finish cleanly. Thanks for any input.
#!/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
What this
is telling me is that your “.mpg.tmp” files resides in
/home/xxx/trans-out, and you’re trying to move them (probably renamed to “.mpg” too?) to/home/xxx/trans-out/tmp(overwriting “.mpg” files with the same name?).As to why it’s not working, assume that
NEWandOLDdoes indeed contain the list of files as you intended:NEWcontains “new1”, “new2”, “new3”OLDcontains “old1”, “old2”, “old3”The statement
mv $OUTDIR/$OLD $OUTDIR/$NEWwould then expand towhich would mean: move the 5 files (“$OUTDIR/new1”, “new2”, “new3”, “old1”, “$OUTDIR/old2”) to the directory “old3”.
What I suspect would work is replacing that 3 lines with this
(I assumed that the
awkwas for removing ‘.tmp’ from the extension)