2020-07-24, 03:35 AM
OK, this was much easier than I thought, I was just getting in my own head with shell scripting, it all came back to me quickly. I knocked this up in about an hour this evening.
Of course, as always, the real version is more complicated than I made out. Only some channels need recoding, so I created an alternate recording location in ToRecode to place files that need to be recoded. In the script, I only rename files that are in ToRecode.
Martrin, what was the point in the dotnet command in your script, do I need to include that to make NextPVR do something?
Of course, as always, the real version is more complicated than I made out. Only some channels need recoding, so I created an alternate recording location in ToRecode to place files that need to be recoded. In the script, I only rename files that are in ToRecode.
Martrin, what was the point in the dotnet command in your script, do I need to include that to make NextPVR do something?
Code:
#!/bin/bash
infile=$1
# only move files in the recode location
if [[ "$1" == *"ToRecode"* ]]; then
# use string matching to replace ToRecode with Recode in the path
plex_file="${infile/ToRecode/Recode}"
# create target dir in case it does not yet exist
target_dir=$(dirname "$plex_file")
mkdir -p $target_dir
# move the file to the Plex location
mv "$1" "$plex_file"
fi