Skip to content

Instantly share code, notes, and snippets.

@BrianZbr
Created April 24, 2023 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianZbr/bb3205cd0f03b512fcd92f033aea4193 to your computer and use it in GitHub Desktop.
Save BrianZbr/bb3205cd0f03b512fcd92f033aea4193 to your computer and use it in GitHub Desktop.
Create an SRT file from a VideoSubFinder TXTImages folder
#!/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