Last active
July 7, 2023 02:12
-
-
Save nggit/5ef86df5ab6a67cd3fe0218f2c2fd3f8 to your computer and use it in GitHub Desktop.
Expand subtitle (srt) range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
INFILE="file.srt" | |
OUTFILE="out-$INFILE" | |
START= | |
tac "$INFILE" | while IFS= read -r line; do | |
if sub_range="$( echo "$line" | grep " --> " )"; then | |
END="$( echo "$sub_range" | cut -d" " -f3 )" | |
if [ -n "$START" ]; then | |
END="$START,${END##*,}" | |
fi | |
START="$( echo "$sub_range" | cut -d" " -f1 )" | |
echo "$START --> $END" | |
START="${START%%,*}" | |
else | |
echo "$line" | |
fi | |
done | tac > "$OUTFILE" # simpan | |
# tampilkan hasil | |
cat "$OUTFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment