C-Command Software Forum

Applescript syntax

I am trying to use an Applescript for the PDF services so that I can name the pdf file rather than just accepting the default.
However, I can’t figure out the appropriate syntax from the example in the manual or the dictionary. My script:

on open dropped_item
set this_file to item 1 of dropped_item
tell application “Finder”
activate
set the file_name to the name of this_file
set the parent_folder to the container of this_file
repeat
display dialog “Enter a name for file:” default answer file_name
set this_name to the text returned of the result
if this_name is not “” then
if this_name does not end with “.pdf” then
set this_name to this_name & “.pdf”
end if
exit repeat
end if
end repeat
set the name of this_file to this_name
set this_file to (item this_name of the parent_folder) as alias
end tell

tell application "EagleFiler"
	import "Eagle Filer Test" files this_file
end tell

end open

I also tried using the full path for the library and a script like the manual with just the name and also the full path, but none will compile

tell application “EagleFiler”
tell library “Eagle Filer Mail”
import files this_file
end tell

What is the proper syntax for identifying the library to which you want to import the file?

PDF Services Script to “Save PDF to EagleFiler (Ask For Filename)”
This is working for me:

on open dropped_item
    set this_file to item 1 of dropped_item
    tell application "Finder"
        activate
        set the file_name to the name of this_file
        set the parent_folder to the container of this_file
        repeat
            display dialog "Enter a name for file:" default answer file_name
            set this_name to the text returned of the result
            if this_name is not "" then
                if this_name does not end with ".pdf" then
                    set this_name to this_name & ".pdf"
                end if
                exit repeat
            end if
        end repeat
        set the name of this_file to this_name
        set this_file to (item this_name of the parent_folder) as alias
    end tell
    
    tell application "EagleFiler"
        tell library document 1
            import files {this_file}
        end tell
    end tell
end open

It will import the PDF into the frontmost library. In order to specify the library in the script, you can do something like this:

tell application "EagleFiler"
    open POSIX file "/Users/mjt/Test/Test.eflibrary"
    tell document "Test.eflibrary"
        import files {this_file}
    end tell
end tell

PDF services script
Merci. I feel sort of “duh” for not recognizing that "library document " was the object.

In your example for a specific library shouldn’t it be:

tell library document “Test.eflibrary”

rather than

tell document “Test.eflibrary”

Both should work.

Hmmm… can’t download the attachment. (downloads as .php file in both Safari and SpeedDownload).

Suggestions?

thanks :slight_smile:

It works fine for me in Safari if I just click the link. It starts out as attachment.php and then the name changes to EagleFilerPDFService.scpt.zip. Perhaps if you just rename the file that you downloaded it will work.