Skip to content

Instantly share code, notes, and snippets.

@extratone
Forked from jasonsnell/podcast-noter.scpt
Created January 15, 2022 16:22
Show Gist options
  • Save extratone/c9965888f1ecfd76748424977a497878 to your computer and use it in GitHub Desktop.
Save extratone/c9965888f1ecfd76748424977a497878 to your computer and use it in GitHub Desktop.
Podcast Noter AppleScript
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
# Sample Keyboard Maestro macros at
# <https://sixcolors.com/wp-content/uploads/2022/01/Podcast-Noter-Macros.kmmacros.zip>
on run argv
try
set theNote to (item 1 of argv)
on error
set theNote to ""
end try
set theSavePath to "/Users/jsnell/Desktop/" -- put your own path here
set theDatematch to (do shell script "date '+%Y%m%d'")
set theLatestMatch to date "Monday, January 1, 2001 at 12:00:00 AM"
try
tell application "Finder"
set theMatches to (every file of (POSIX file theSavePath as alias) whose name contains theDatematch)
set theWinner to item 1 of theMatches
repeat with i from 1 to (count of items in theMatches)
set theMatched to creation date of item i of theMatches
if theMatched > theLatestMatch then
set theLatestMatch to theMatched
set theWinner to item i of theMatches
end if
end repeat
set theStartTime to (creation date of theWinner)
end tell
on error
display notification "No session found."
return
end try
set theOffset to ((current date) - theStartTime)
set theTimeStamp to secondstoHMS from theOffset
if (theNote as text) = "" then
set theStamper to theTimeStamp
else
set theStamper to (theTimeStamp & " - " & (theNote as text))
end if
set theSafeDatematch to (do shell script "date -j -f '%A, %B %e, %Y at %I:%M:%S %p' '" & theStartTime & "' '+%b %d %H%M'")
do shell script ("echo " & quoted form of theStamper & " >> " & quoted form of (theSavePath & "Notes - " & theSafeDatematch & ".txt"))
end run
on secondstoHMS from theSeconds
tell theSeconds to return my pad(it div hours) & ":" & my pad(it mod hours div minutes) & ":" & my pad(it mod minutes)
end secondstoHMS
on pad(v)
return text -2 thru -1 of (v + 100 as text)
end pad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment