Applescript for easier importing of .ris, .enw, etc., files.

As has been noted elsewhere, double-cliicking on a .ris or .enw file in order to import it to EN has a hitch.  Rather than importing into the default or open library, EN willl put up an Open File dialog in which you have to choose the library.  Particularly if your computer is strangely slow to open that dialog, as mine is, this is really irritating.  So, I’ve written some AppleScript that goes the other way.  It opens the your “default” library in EN and then imports the file in question.  I’ve posted it below.

A few notes:

  1. Obviously, you’ll have to change the names of the library.

  2. You’ll get a warning about the program trying to use accessibility features.  You can hit “okay” and only need to do so once.

  3. I’m running this from Hazel, which automatically detects when I’ve downloaded a .enw or .ris file.  Hazel provides the information for “theFile”, which includes its full path.  You can come up with other ways to designate “theFile”.  One option this opens is iterating through a bunch of .enw/.ris files you want to import, e.g, “repeat with theFile in filesToImport”…

  4. I’m not sure the delay statements need to be as long as they are or are necessary at all.

  5. Comments and improvements welcome.

    tell application “EndNote X7”
    open “/Users/ghoetker/Documents/GPH_Endnote_2012.enlp/”
    end tell

    delay 0.3

    tell application “System Events” to tell application process “EndNote X7”
    click menu item “Import…” of menu “File” of menu bar 1
    delay 0.5
    keystroke “g” using {shift down, command down}
    set value of text field 1 of sheet 1 of sheet 1 of window 1 to theFile
    clickbutton “Go” of sheet 1 of sheet 1 of window 1
    click button “Import” of sheet 1 of window 1
    end tell

    tell application “Finder”
    end tell

 Hope someone finds it helpful.