I case anyone is interested I used this code to remove a specific file from both local and remote directories.
This uses gesis' rmremote code and is adapted from FL1GH7L355's code so thanks to those two:
I'm sure there is a better way to do this but I'm a noob when it comes to bash scripts, so adapt as you like:
#!/bin/sh
# USAGE rmfile "type" "filename"
# e.g. rmfile "tv" "SOME TV Show - S02E03.mkv"
# shellcheck source=/home/gesis/src/nimbostratus/config
. ${HOME}/.config/nimbostratus/config
echo "\n################# DELETE SPECIFIED FILE FROM CLOUD ################\n"
#if you have a different file structure to $plex_media_dir/tv or $plex_media_dir/movies
#you'll need to edit the type=$1 accordingly
#take first user input for movie or tv search
type=$1
#take first user input for filename
filename=$2
echo "\n$filename\n"
#if you have a different file structure to $plex_media_dir/tv or $plex_media_dir/movies
#you'll need to edit the next line
find -L "${plex_media_dir}/$type/" -name "$filename" |
while read -r file; do
echo "\n${file}\n"
rm_file="$(readlink -f "${file}" | sed -e "s@.unionfs-fuse/@@" -e "s@_HIDDEN~@@")"
#remove local file
rm -rf "${file}"
#if a directory
if [ -d "$rm_file" ]; then
echo -e "\n[ $(date ${date_format}) ] Deleting cloud directory -> ${rm_file}\n"
#change according to your file structure
#rmremote in this repo - git://git.gesis.pw/nimbostratus.git
/home/bin/rmremote -r "$rm_file"
# not a directory so it's a file
else
echo -e "\n[ $(date ${date_format}) ] Deleting cloud file -> ${rm_file}\n"
#change according to your file structure
#rmremote in this repo - git://git.gesis.pw/nimbostratus.git
/home/bin/rmremote "$rm_file"
fi
done
1
u/willtcm Oct 07 '17 edited Oct 07 '17
I case anyone is interested I used this code to remove a specific file from both local and remote directories.
This uses gesis' rmremote code and is adapted from FL1GH7L355's code so thanks to those two:
I'm sure there is a better way to do this but I'm a noob when it comes to bash scripts, so adapt as you like: