diff --git a/README b/README new file mode 100644 index 0000000..e8895b4 --- /dev/null +++ b/README @@ -0,0 +1,6 @@ +This script is linux only based in bash. It's needs find, , sed, sickbeard_mp4_automator and all of it's dependencies. + +To use the script you /location/to/script/run.sh "location" extension_without_period amount_of_files + +You can specify the amount of files or "a" for all of them. + diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..404b1b7 --- /dev/null +++ b/run.sh @@ -0,0 +1,37 @@ +#!/bin/bash +sicklocation="/opt/sickbeard_mp4_automator/manual.py" #Location of sickbeard_mp4_automator +tsdate="/root/scripts/rawhdconvert/ts.$(date +'%Y%m%d')" #Create current date and time +tsdatec=$tsdate # Not sure why I did this +ts="/root/scripts/rawhdconvert/ts" # location of ts. TS is the temp file that holds files to be converted +location="$1" # Folder you want to search in +type="$2" # File extension without the . of what you want to be converted +num="$3" # Amount of files you want to be converted +EMAIL_TO="email@site.net" # Where you want it to email when done being converted + +function run { + sed -i 's#^#python '$sicklocation' -i "#' $ts + sed -i 's#$#" -a#' $ts + date +'%Y%m%d_%H%M' >> $tsdate + find "$location" -iname "*."$type"" -type f -exec du -hsc {} + | tail -1 >> $tsdate + cat $ts >> $tsdate + chmod +x $ts + sh $ts + rm $ts + find "$location" -iname "*."$type"" -type f -exec du -hsc {} + | tail -1 >> $tsdate + date +'%Y%m%d_%H%M' >> $tsdatec + echo "Finished Converting" | mutt -a "$tsdate" -s "Finished Converting" -- "$EMAIL_TO" +} + +if [ -f $ts ] + then + echo "Already Running" + else + if [ $num == "a" ] + then + find "$location" -iname "*."$type"" -type f >> $ts + run + else + find "$location" -iname "*."$type"" -type f | tail -$num >> $ts + run + fi +fi