I am trying to write a folder action script that takes PDF and uses Acrobat to convert them into EPS.
Here is what I have so far:
on adding folder items to this_folder after receiving added_items
set the item_count to the number of items in the this_folder
repeat with i from 1 to number of items in this_folder
set this_item to item i of items in this_folder
if this_item does not end with ".pdf" then
display dialog "An item in this folder does not appear to be a PDF. Would you like to continue anyway?" buttons {"yes", "no"} default button 2
if the button returned of the result is "no" then
exit repeat
end if
else
tell application "Adobe Acrobat Professional"
open this_item
save this_item to this_folder using EPS Conversion
end tell
end if
end repeat
end adding folder items to
I get no response from the folder regardles of what file i put in, and it is not obvious to me what I am doing wrong as I am quite a novice at this.
Hi,
folder action scripts abort silently in case of an error.
I recommend always to debug the script by commenting out the event handler line and
defining the variables this_folder and added_items.
One error is in the line
if this_item does not end with ".pdf" then
this_item is an alias, not a file name
another in the line
save this_item to this_folder using EPS Conversion
Acrobat cannot save an alias (this_item) to a folder alias.
You have to specify the full path including the file name and the proper extension
on adding folder items to this_folder after receiving added_items
repeat with oneItem in added_items
set {name:Nm, name extension:Ex} to (info for oneItem)
set baseName to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
if Ex is not "pdf" then
display dialog "An item in this folder does not appear to be a PDF. Would you like to continue anyway?" buttons {"yes", "no"} default button 2
if the button returned of the result is "no" then exit repeat
else
tell application "Adobe Acrobat Professional"
open oneItem
save document 1 to file ((this_folder as text) & baseName & ".eps") using EPS Conversion
close document 1 saving no
end tell
end if
end repeat
end adding folder items to
It’s not recommended to save the converted files in the hot folder, because the folder action will be triggered again