Has anyone tried to make a script that consolidated files that were scattered across different disks? For example, I had tv shows, music and movies in a "media" share (Media/TV/Shows/Show_name/Season_X/file, Media/TV/Anime/Anime_name/Season_X/file, Media/Movies/Movie_name/file.
My split level kept all the episodes of a season together on a single disk. My issue was the movie subtitles were being downloaded and split onto whatever disk had the space, sometimes having more than one drive spin up to access the movie and the subtitles.
Tried using ChatGPT to help with a script and this is what it came up with:
#!/bin/bash
# Set the path to your movie directory
MOVIE_DIR="/mnt/user/Movies"
# Find all movie files and loop through them
find "$MOVIE_DIR" -type f \( -iname "*.mkv" -o -iname "*.mp4" -o -iname "*.avi" \) -print0 | while IFS= read -r -d '' movie; do
movie_dir=$(dirname "$movie")
movie_name=$(basename "$movie")
movie_name="${movie_name%.*}"
# Find the corresponding .srt file
srt_file=$(find "$movie_dir" -type f -iname "$movie_name.srt" -print -quit)
# Move the .srt file to the same directory as the movie file
if [ -n "$srt_file" ]; then
mv "$srt_file" "$movie_dir"
echo "Moved $srt_file to $movie_dir"
fi
done