Created
April 24, 2023 22:44
-
-
Save BrianZbr/bb3205cd0f03b512fcd92f033aea4193 to your computer and use it in GitHub Desktop.
Create an SRT file from a VideoSubFinder TXTImages folder
This file contains 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
#!/bin/bash | |
outfile="output.srt" | |
main(){ | |
i=0 | |
for filename in *.txt; do | |
no_unders="${filename//_}" | |
start_hour="${no_unders:0:1}" | |
start_min="${no_unders:1:2}" | |
start_sec="${no_unders:3:2}" | |
start_ms="${no_unders:5:3}" | |
end_hour="${no_unders:8:1}" | |
end_min="${no_unders:9:2}" | |
end_sec="${no_unders:11:2}" | |
end_ms="${no_unders:13:3}" | |
echo "$i" | |
echo "0$start_hour:$start_min:$start_sec,$start_ms --> 0$end_hour:$end_min:$end_sec,$end_ms" | |
cat $filename | tr '\n' ' ' | |
echo -e "\n" | |
i=$((i+1)) | |
done | |
} | |
echo "Writing $outfile, please wait..." | |
main > $outfile | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment