From 36fb93790a96277d192d1356cdb473c72bf9d1c8 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sun, 6 Mar 2022 14:14:22 -0600 Subject: [PATCH] Added rename-subs --- rename-subs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rename-subs diff --git a/rename-subs b/rename-subs new file mode 100644 index 0000000..42860d0 --- /dev/null +++ b/rename-subs @@ -0,0 +1,18 @@ +#!/bin/sh + +# It renames the .srt files in a directory to match the .mp4 movie names (since those are the formats I usually need). +# 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..." + n=$(find . -maxdepth 1 -name "*.srt" -printf '.' | wc -m) + if [ $n -eq 1 ] && ! [ -f $h.srt ]; then + mv *.srt $h.srt + echo "Done!" + else + echo "Unable to find unique srt file that needs to be renamed." + fi + fi +done \ No newline at end of file