I’m trying to write an Applescript which tells EF to file something based on parameters passed to it. It adapts this previous forum entry EagleFiler - Hazel Script Integration… Import into EF and let EF check duplicates with just a few changes.
on hazelProcessFile(_file, _inputAttributes)
-- Get the parent folder, subfolder, and library that you set in Hazel
set _parentFolderName to item 1 of _inputAttributes
set _folderName to item 2 of _inputAttributes
set _efLibrary to item 3 of _inputAttributes
-- Change these to the library that you want to use
set _libraryName to _efLibrary & ".eflibrary"
set _libraryFolder to "/Users/jeep/Library/Mobile Documents/com~apple~CloudDocs/EagleFiler/" & _efLibrary
set _libraryFile to POSIX file _libraryFolder & "/" & _libraryName
tell application "EagleFiler"
try
open _libraryFile
tell library document _libraryName
set _folderRecord to library record _folderName of library record _parentFolderName of root folder
set {_record} to import files {_file} container _folderRecord
end tell
on error errStr number errorNumber
display dialog errStr & " : " & number & " : " & errorNumber
error errStr number errorNumber
end try
end tell
end hazelProcessFile
For completeness, here’s the Applescript I use in Hazel to set the parameters
set efLibrary to "General"
set efParentFolder to "TestFolder"
set efFolder to "TestSubFolder"
return {hazelOutputAttributes:{efLibrary, efParentFolder, efFolder}}
It works… up to a point. The file is correctly loaded into the right subfolder. However… then it goes a bit haywire
… and it hangs for a bit. If a duplicate file is then thrown into the mix, EF has to be forced quit. Hope someone can explain why my beyond-rudimentary Applescript and EF knowledge is breaking! Many thanks.