2022-03-06 14:14:22 -06:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# It renames the .srt files in a directory to match the .mp4 movie names (since those are the formats I usually need).
|
2022-05-26 20:39:51 -05:00
|
|
|
# If the subtitles are in a subfolder, the script should still work as long as there's only one .srt file.
|
2022-03-06 14:14:22 -06:00
|
|
|
# It makes the subs discoverable by virtually any video player.
|
|
|
|
|
|
|
|
for f in *.mp4; do
|
|
|
|
if [ -f "$f" ]; then
|
|
|
|
h=$(basename "$f" .mp4)
|
|
|
|
echo "Renaming the subtitle (if any) accompanying $h.mp4..."
|
2022-05-26 20:39:51 -05:00
|
|
|
n=$(find . -maxdepth 2 -name "*.srt" -printf '.' | wc -m)
|
2022-03-06 14:14:22 -06:00
|
|
|
if [ $n -eq 1 ] && ! [ -f $h.srt ]; then
|
2022-05-26 20:39:51 -05:00
|
|
|
find . -maxdepth 2 -name "*.srt" -exec mv {} $h.srt \;
|
2022-03-06 14:14:22 -06:00
|
|
|
echo "Done!"
|
|
|
|
else
|
|
|
|
echo "Unable to find unique srt file that needs to be renamed."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|