I'm trying to make a folder action to enable pdfs in Acrobat 8

Hello again. I’m trying to attach a folder action to a folder that will enable the mark-up capabilities in acrobat 8 for pdfs dropped in a folder. Any help would be greatly appreciated.


property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.

on adding folder items to this_folder after receiving added_items
	try
		tell application "Finder"
			set fileNameList to (every file in entire contents of the_folder whose name ends with ".pdf") as alias list
		end tell
	end try
end adding folder items to
tell application "Adobe Acrobat Professional"
	activate
	try
		repeat with iFile from 1 to count fileNameList
			set thisFilePath to item iFile of fileNameList
			set thisFilePath to thisFilePath as string
			open file thisFilePath
			
			tell application "System Events"
				tell process "Acrobat"
					delay 0.25
					click menu item "Enable Usage Rights in Adobe Reader..." of menu 1 of menu bar item "Advanced" of menu bar 1
					delay 0.25
					keystroke return
					delay 0.25
					keystroke return
					delay 0.25
					keystroke return
					delay 0.5
					tell window 1
						repeat until exists button "Replace" of sheet 1
							delay 0.25
						end repeat
						click button "Replace" of sheet 1
						tell application "Adobe Acrobat Professional"
							close last document
							
						end tell
					end tell
				end tell
			end tell
		end repeat
	end try
end tell

Hi Chuck,

Your posted code cannot work. When the folder action is called, it executes the «on adding folder items» handler, which creates an alias list of the found PDF files. But it won’t execute the code addressing Adobe Acrobat outside the «on adding folder items» handler. To do so, you need to create a subroutine or to integrate the code right into the folder action handler. I don’t have Acrobat installed on my Mac, so the following code might not be perfect, but may point you in the right direction:


property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.

on adding folder items to this_folder after receiving added_items
	try
		tell application "Finder"
			set fileNameList to (every file in entire contents of the_folder whose name ends with ".pdf") as alias list
		end tell
		repeat with fileName in fileNameList
			my doacrobataction(fileName)
		end repeat
	end try
end adding folder items to

on doacrobataction(fileAlias)
	try
		tell application "Adobe Acrobat Professional"
			activate
			set thisFilePath to fileAlias as string
			open file fileAlias
			tell application "System Events"
				tell process "Acrobat"
					delay 0.25
					click menu item "Enable Usage Rights in Adobe Reader..." of menu 1 of menu bar item "Advanced" of menu bar 1
					delay 0.25
					keystroke return
					delay 0.25
					keystroke return
					delay 0.25
					keystroke return
					delay 0.5
					tell window 1
						repeat until exists button "Replace" of sheet 1
							delay 0.25
						end repeat
						click button "Replace" of sheet 1
						tell application "Adobe Acrobat Professional"
							close last document
						end tell
					end tell
				end tell
			end tell
		end tell
	end try
end doacrobataction

set the_container to choose folder
tell application “Finder”
try
set fileNameList to (every file in entire contents of the_container whose name ends with “.PDF”) as alias list
on error
set fileNameList to (every file in entire contents of the_container whose name ends with “.pdf”) as alias as list
end try
end tell

activate application “Adobe Acrobat Professional”
tell application “Adobe Acrobat Professional”
repeat with iFile from 1 to count fileNameList
set thisFilePath to item iFile of fileNameList
set thisFilePath to thisFilePath as string
open file thisFilePath
activate application “Adobe Acrobat Professional”
tell application “System Events”
tell process “Acrobat”
click menu item “Enable Usage Rights in Adobe Reader…” of menu 1 of menu bar item “Advanced” of menu bar 1
tell window 1
repeat until exists button “Save Now”
delay 0.1
end repeat
keystroke return
delay 0.1
keystroke return
repeat until exists button “Replace” of sheet 1
delay 0.1
end repeat
click button “Replace” of sheet 1
end tell
tell application “Adobe Acrobat Professional”
close last document
end tell
end tell
end tell
end repeat
end tell

Cobbled together from the various posts here. Finally works with Acrobat 8 Pro on OS X 10.5.7

Did you get this to work as a folder action? The script works but it would be easier as a folder action. Thanks.