Created
February 28, 2013 21:15
-
-
Save syoutsey/5060186 to your computer and use it in GitHub Desktop.
Get full timestamp (HH:MM:SS) from input (MM:SS, H:MM:SS, H:M:S, etc.)
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 | |
cat $1 | | |
while read cnt tm; do | |
cnt=$((cnt-1)) | |
IFS='.' read -a a <<< "$tm" | |
MVAR=0 | |
SVAR=1 | |
HOUR=00 | |
# check if string has hours included (ex: 01:23:45) | |
if [ -n "${a[2]}" ]; then | |
if [ ${#a[0]} -lt 2 ]; then | |
HOUR="0"${a[0]} | |
MVAR=1 | |
SVAR=2 | |
else | |
HOUR=${a[0]} | |
fi | |
fi | |
# let's keep processing our minutes and seconds | |
if [ ${#a[$MVAR]} -eq 1 ]; then | |
MINUTE="0"${a[$MVAR]} | |
else | |
MINUTE=${a[$MVAR]} | |
fi | |
if [ ${#a[$SVAR]} -lt 2 ]; then | |
SECOND="0"${a[$SVAR]} | |
else | |
SECOND=${a[$SVAR]} | |
fi | |
TIME=$HOUR:$MINUTE:$SECOND | |
echo "{\"kind\":\"image\",\"time\":\"$TIME\",\"filename\":\"slide"$cnt".png\",\"title\":\"\"}," | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment