This is a tricky one. I need to do the following using 2 folders, the movie folder and the subtitle folder:
Search for every movie inside the movie folder, for each file it finds, grab the files name and try to search for it in the subtitle folder.
If the file is found do nothing. If the file is not found, output the file name to a log file that will collect all movies that do not have a subtitle.
The movie folder has the following format:
/Movies
/Movies/SomeMovieFolder1
/Movies/SomeMovieFolder2
/Movies/SomeMovieFolder3
/Movies/SomeMovieFolder...
/Movies/SomeMovieFolderN
And inside each movieFolder is the actual movie (Each movie is in it's own folder inside the Movie folder.
The subtitle folder has all subtitles in the same place. In the subtitles folder.
My thinking would be 2 find
commands looped together using a while. This would be a shell script (bash).
Movies are MP4 or MKV formats. Subtitles are SRT format.
If filenames of the movies and subtitles files match and only the extensions differ, something like this should work.
#!/bin/bash
movie_dir=~/Movies
subtitle_dir=~/Subtitles
log=~/log.txt
for i in "$movie_dir"/*;do
filname="${i%.*}"
if [ ! -e "$subtitle_dir/$filename.srt" ];then
echo "$filename" >> "$log"
fi
done
EDIT For when each movie file is in it's own folder then try:
#!/bin/bash
movie_dir=~/Movies
subtitle_dir=~/Subtitles
log=~/log.txt
find "$movie_dir" -type f -name "*.mp4" -o -name "*.mkv" | while read i;do
filename="$(basename "${i%.*}")"
if [ ! -e "$subtitle_dir/$filename.srt" ];then
echo "$filename" >> "$log"
fi
done
This second way should work regardless of the movie folder structure, again as long as the filenames are the same.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments