Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An old half-finished Applescript where I was looking at automating a download of my pinboard bookmarks into Camino. Been quite a while since I used Camino - dated 2011.
-- pinboard username and password
property pbuser : ""
property pbpass : ""
--Download bookmarks via curl to desktop (because can use shortcut when selecting file for import via UI scripting)
do shell script ("cd ~/Desktop; curl https://" & pbuser & ":" & pbpass & "@pinboard.in/export/ -o pinboard.html")
--import bookmarks via UI scripting
tell application "System Events"
if UI elements enabled then
tell process "Camino"
set frontmost to true
end tell
click menu item "Import Bookmarks…" of menu of menu bar item "File" of menu bar 1 of process "Camino"
click pop up button of window "Import Bookmarks" of process "Camino"
click menu item 5 of menu 1 of pop up button of window "Import Bookmarks" of process "Camino"
keystroke "D" using {command down} --go to desktop downloads?
keystroke "pinboard" --this works as long as no other file called "pinboard not the right file", etc.
keystroke return
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell
--delete the previous pinboard folder
tell application "Camino"
try
with timeout of 120 seconds
delete bookmark folder "pinboard"
end timeout
end try
end tell
--rename the new imported folder
tell application "Camino"
try
set name of bookmark folder "Imported Bookmarks" to "pinboard"
end try
end tell
--delete pinboard file from the desktop --not finished this bit!
tell application "Finder"
move file (((path to desktop) & "pinboard.html") as string) to trash
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment