Move movie out of Parent folder (Edot Script)

Come up with a useful post-processing script? Share it here!
Post Reply
natethegreat141990
Newbie
Newbie
Posts: 4
Joined: July 3rd, 2012, 5:12 pm
Location: Acworth Ga

Move movie out of Parent folder (Edot Script)

Post by natethegreat141990 »

Yes I have a script that I run and I would like for it to at the end to move the movie out of the downloaded folder into its parent folder so that it moves from "/home/User/Downloads/Movies/Downlaoded_folder/Movie.avi" to /home/User/Downloads/Movies/Movie.avi". Now here is the script that is currently being ran. I would also like it to delete the empty folder afterwards.


#!/bin/sh
#
# classify_and_combine-movie.sh
#

set -u
COMBINE=1 # to combine or not to combine multi-file movies (will mess up subs)
TMP="/tmp/sabtmp.out"
CATEGORY_NAME=`echo $1 | awk -F [/] '{print $(NF-1)}'`
echo "Category: $CATEGORY_NAME"
FOLDER_PATH="$1"
FOLDER_NAME=`echo $FOLDER_PATH | awk -F [/] '{print $NF}'`
echo "Folder Path: $FOLDER_PATH"

cd "$FOLDER_PATH"

MOVIE_NAME=`echo $FOLDER_NAME | sed 's/ (.*)//g'`

# remove movie sample files (anything under 30MB)
if [ `find . -size -30000000c -regex '.*/.*\.avi' | wc -l` -eq 1 ]
then
FILE3="$FOLDER_PATH`find . -size -30000000c -regex '.*/.*\.avi' | sed 's/^\.//'`"
echo "Removing Sample: ${FILE3}"
rm -f "${FILE3}"

fi

# combine 2 CD movies into 1 file (this will break subs)
if [ "${COMBINE}" = "1" ]; then
if [ `find . -size +629145600c -regex '.*/.*\.avi' | wc -l` -eq 2 ]
then
FILE1="$FOLDER_PATH`find . -size +629145600c -regex '.*/.*\.avi' | sort | sed -n '1p' | sed 's/^\.//'`"
FILE2="$FOLDER_PATH`find . -size +629145600c -regex '.*/.*\.avi' | sort | sed -n '2p' | sed 's/^\.//'`"
echo "Joining Files ${FILE1} and ${FILE2} ..."
avimerge -i "${FILE1}" "${FILE2}" -o "$FOLDER_PATH/$MOVIE_NAME".avi 2> /dev/null 1> /dev/null
#mencoder -msglevel all=3 -forceidx -ovc copy -oac copy -o "$FOLDER_PATH/$MOVIE_NAME".avi "${FILE1}" "${FILE2}"
echo "Removing Files ${FILE1} and ${FILE2} ..."
rm -f "${FILE1}"
rm -f "${FILE2}"
elif [ `find . -size +629145600c -regex '.*/.*\.avi' | wc -l` -eq 1 ]
# if only one part, rename it
then
FILE1="$FOLDER_PATH`find . -size +629145600c -regex '.*/.*\.avi' | sort | sed -n '1p' | sed 's/^\.//'`"
echo "Renaming File ${FILE1} to '$FOLDER_PATH/$MOVIE_NAME'.avi ..."
mv "${FILE1}" "$FOLDER_PATH/$MOVIE_NAME".avi

fi
fi

# Generate AppleTV/ATVFiles XML file for movie & download cover
atv2xml.pl -usedir -usefirst -overwrite -duration -altimg "$FOLDER_PATH" > $TMP
cat $TMP

# Change perms on directory
chmod -R 777 "$FOLDER_PATH"

cat $TMP | growlnotify.pl
rm -f $TMP

Now I would like it to be ran after it does all the renaming of the movie and such. Thanks in advance for any help. If you have questions please feel free to ask me.
Post Reply