Skip to content

Instantly share code, notes, and snippets.

@sergiolopes
Last active April 3, 2018 17:48
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 sergiolopes/382e89c548bf6da47f5795760e17fd49 to your computer and use it in GitHub Desktop.
Save sergiolopes/382e89c548bf6da47f5795760e17fd49 to your computer and use it in GitHub Desktop.
Retorna o tempo total em segundos de um arquivo do ScreenFlow
#!/bin/bash
# Retorna o tempo total em segundos de um arquivo do ScreenFlow
#
# Requisito: Dar permissão de acessibilidade pro Terminal ou outra App que vai executar
# (System Preferences > Security & Privacy > Privacy > Accessibility > Add Application)
file=$1
if [ "$file" = "" ] || [ ! -d "$file" ]; then
echo Passe o nome do arquivo pra detectar a duração
exit 1
fi
duration=$(osascript <<END
tell application "ScreenFlow" to open "$1"
tell application "System Events" to tell process "ScreenFlow"
repeat with el in UI elements of scroll area 1 of window 1
if (value of el as text) starts with "Duration" then set temp to value of el
end repeat
end tell
get temp
END
)
mins=$(echo $duration | grep -o "[0-9]\+ mins" | sed -e 's/ mins//')
secs=$(echo $duration | grep -o "[0-9]\+ secs" | sed -e 's/ secs//')
echo $(( mins * 60 + secs ))
tell application "ScreenFlow" to open "/tmp/Untitled.screenflow"
tell application "System Events" to tell process "ScreenFlow"
repeat with el in UI elements of scroll area 1 of window 1
if (value of el as text) starts with "Duration" then set temp to value of el
end repeat
end tell
get temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment