mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-26 13:18:35 -06:00
new: Add language support for rename-subs
This commit is contained in:
parent
5b5f9951ed
commit
e9e3134c7e
1 changed files with 4 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
# It renames the .srt files in a directory to match the .mp4 movie names (since those are the formats I usually need).
|
# It renames the .srt files in a directory to match the .mp4 movie names (since those are the formats I usually need).
|
||||||
# If the subtitles are in a subfolder, the script should still work as long as there's only one .srt file.
|
# If the subtitles are in a subfolder, the script should still work as long as there's only one .srt file.
|
||||||
# It makes the subs discoverable by virtually any video player.
|
# It makes the subs discoverable by virtually any video player.
|
||||||
|
# Optionally takes a language arguments e.g. en to rename to .en.srt
|
||||||
|
|
||||||
for f in *.mp4; do
|
for f in *.mp4; do
|
||||||
if [ -f "$f" ]; then
|
if [ -f "$f" ]; then
|
||||||
|
@ -10,7 +11,9 @@ for f in *.mp4; do
|
||||||
echo "Renaming the subtitle (if any) accompanying $h.mp4..."
|
echo "Renaming the subtitle (if any) accompanying $h.mp4..."
|
||||||
n=$(find . -maxdepth 2 -name "*.srt" -printf '.' | wc -m)
|
n=$(find . -maxdepth 2 -name "*.srt" -printf '.' | wc -m)
|
||||||
if [ $n -eq 1 ] && ! [ -f "$h.srt" ]; then
|
if [ $n -eq 1 ] && ! [ -f "$h.srt" ]; then
|
||||||
find . -maxdepth 2 -name "*.srt" -exec mv "{}" "$h.srt" \;
|
# Check if language was given
|
||||||
|
[ -z $1 ] && ext="srt" || ext="$1.srt"
|
||||||
|
find . -maxdepth 2 -name "*.srt" -exec mv "{}" "$h.$ext" \;
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
else
|
else
|
||||||
echo "Unable to find unique srt file that needs to be renamed. It might already have the proper name."
|
echo "Unable to find unique srt file that needs to be renamed. It might already have the proper name."
|
||||||
|
|
Loading…
Reference in a new issue