Script to automatically make a new bookmark folder in Skim for each PDF and store every bookmark created in it’s respective folder

applescriptautomationbookmarkspdfskim

Skim by default makes every new bookmark in the bookmark menu for all the pdf's, even if I create a bookmark folder for the pdf manually, there is no way of making it save the bookmark in this folder automatically because in the save bookmark dialogue by default the Add To field will show Bookmarks Menu as the default location, which I have to manually change to the folder I created each time. So I was wondering if there is a applescript method of automating all this so, a bookmark folder will be automatically created when I save the first bookmark and every consequent bookmark will be automatically saved into this folder.

Best Answer

Apparently Skim has a nice Wiki, which covers much, including Wiki: AppleScript and has quite a few scripts available. One of which is called: Synchronize Folder Bookmark

Also read the section on the Script Menu.


Synchronize Skim Folder Bookmark.scpt

(*
Folder Action script to keep a Skim folder bookmark synchronized with the contents of a folder.
• Save this in ~/Library/Scripts/Folder Action Scripts
• Select the folder in Finder
• Choose Services > Folder Actions Setup… from the main or contextual menu
• Select this script
*)

on adding folder items to theFolder after receiving addedItems
    my synchronizeFolderBookmark(theFolder as alias)
end adding folder items to

on removing folder items from theFolder after losing removedItems
    my synchronizeFolderBookmark(theFolder as alias)
end removing folder items from

on run
    my synchronizeFolderBookmark((choose folder) as alias)
end run

on synchronizeFolderBookmark(theFolder)

    set theName to displayed name of (get info for theFolder)

    tell application "Skim"

        set wasRunning to running

        if (bookmark theName exists) and (type of bookmark theName is folder bookmark) then
            make new bookmark with data theFolder at bookmark theName
        else
            make new bookmark with data theFolder
        end if

        if not wasRunning then quit

    end tell

end synchronizeFolderBookmark