Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- RED='\033[0;31m'
- CYAN='\033[0;36m'
- RESET='\033[0m'
- # The script runs and trickplay folders that don't match the name of the movie are removed.
- # in the sample below, the first trickplay folder would be removed since the movie has [pass1][transcoded] in the name
- # find trickplay folders and write to txt file
- # this is what the find output looks like for trickplay folders
- # ./movies/Example movie 1 [1252]/Example movie 1 [1252][DV HDR10].trickplay
- # ./movies/Example movie 1 [1252]/Example movie 1 [1252][DV HDR10][pass1][transcoded].trickplay
- find -name *.trickplay > trickplay.txt
- # find mkv and mp4 files and write to txt file
- # this is what the find output looks like for a movie file
- # ./movies/Example movie 1 [1252]/Example movie 1 [1252][DV HDR10][pass1][transcoded].mkv
- find -name *.mkv -o -name *.mp4 > movies.txt
- # read the movies.txt file line by line
- while read movie
- do
- # write only the basename without the extension to the log.txt for comparison later
- # Example movie 1 [1252][DV HDR10][pass1][transcoded]
- base=$(basename -s .mkv $(basename -s .mp4 "$movie"))
- echo $base >> log.txt
- done < movies.txt
- # read the trickplay.txt file line by line
- while read trickplay
- do
- # Compare only the basename without the extension to log.txt from before
- # Example movie 1 [1252][DV HDR10]
- # Example movie 1 [1252][DV HDR10][pass1][transcoded]
- base=$(basename -s .trickplay "$trickplay")
- # if the trickplay basename matches exactly in log.txt, keep it else remove it
- if ( cat log.txt | grep -qFx "$base"); then
- echo $base >> keep.txt
- else
- echo $base >> remove.txt
- # rm trickplay folders not matching
- rm "$trickplay" -r
- fi
- done < trickplay.txt
- echo -e "${CYAN}List of mp4 and mkv files\n\n${RESET}"
- cat log.txt
- echo -e "\n\n${CYAN}List of trickplay to keep\n\n${RESET}"
- cat keep.txt
- if [ -f remove.txt ]; then
- echo -e "\n\n${RED}List of trickplay folders removed${RESET}"
- cat remove.txt
- fi
- rm *.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement