I have the following code and after the transcode finishes i wish to move the newly created file. But only after, i don't want to write to the other folder as it trancodes. That is why i presume using exec is better as this will only be processed if the previous exec read true. Also note that there maybe more than one file in the current folder.
#!/bin/bash
#
# Change this to specify a different handbrake preset. You can list them by running: "HandBrakeCLI --preset-list"
#
PRESET="AppleTV 2"
if [ -z "$1" ] ; then
TRANSCODEDIR="/path/to/folder"
else
TRANSCODEDIR="$1"
fi
find "$TRANSCODEDIR"/* -type f -exec bash -c 'HandBrakeCLI -i "$1" -o "${1%.*}".mp4 -- preset="$PRESET"' __ {} \; -exec rm {} \;
My little knowledge of linux i thought maybe:
#!/bin/bash
#
# Change this to specify a different handbrake preset. You can list them by running: "HandBrakeCLI --preset-list"
#
PRESET="AppleTV 2"
if [ -z "$1" ] ; then
TRANSCODEDIR="/path/to/folder"
else
TRANSCODEDIR="$1"
fi
find "$TRANSCODEDIR"/* -type f -exec bash -c 'HandBrakeCLI -i "$1" -o "${1%.*}".mp4 -- preset="$PRESET"' __ {} \; -exec rm {} \; -exec mv '"${1%.*}".mp4' "/path to/converted/folder" \;
But this just puts out:
mv: cannot stat â"${1%.*}".mpâ4: No such file or directory
Now i thought maybe this was some characters from notepad++ hiding in there somewhere so i ran it through dos2uunix. But still i am getting the same error.
Now i thinking that "${1%.}".mp4 isn't actually getting the newly create file rather it is looking for a file called "${1%.}".mp4, which doesn't exist.
Any help would be appreciated.