App/Droplet Question

Hello

I need to create a script that will open a bunch of PDF files and then run Extend Features in Adobe Reader. So far I have that working. I have saved it as an app and can drop pdf files directly onto it and it works fine.

Is there a way to make it so that I can drop a folder onto the icon and it will open all the files within that folder and any sub-folders in their default application?

on open PdfFiles
	tell application "Adobe Acrobat Pro"
		repeat with PdfFile in PdfFiles
			open PdfFile
			tell application "System Events"
				tell process "Acrobat"
					click menu item "Extend Features in Adobe Reader..." of menu "Advanced" of menu bar item "Advanced" of menu bar 1
					try
						click button "Save Now" of window "Enable Usage Rights in Adobe Reader"
						click button "save" of window "Save"
						click button "Replace" of sheet 1 of window "save"
					end try
					try
						click button "OK" of window "Enable Usage Rights in Adobe Reader"
					end try
				end tell
			end tell
			close front document saving no
		end repeat
	end tell
end open

Hi,

this droplet scans the entire contents of the dropped folders for all PDF files.
You can use the normal find or - more specific - a Spotlight search with mdfind


on open theItems
	repeat with anItem in theItems
		tell application "System Events" to set isFolder to (class of item (anItem as text) is folder)
		if isFolder then
			set pdFiles to paragraphs of (do shell script "find " & quoted form of POSIX path of anItem & " -name '*.pdf'")
			-- or using Spotlight
			-- set pdFiles to paragraphs of (do shell script "mdfind -onlyin " & quoted form of POSIX path of anItem & " 'kMDItemContentType = \"com.adobe.pdf\"'")
			repeat with aFile in pdFiles
				set aFilePath to POSIX file aFile as text
				tell application "Adobe Acrobat Pro"
					open aFilePath
					tell application "System Events"
						tell process "Acrobat"
							click menu item "Extend Features in Adobe Reader..." of menu "Advanced" of menu bar item "Advanced" of menu bar 1
							try
								click button "Save Now" of window "Enable Usage Rights in Adobe Reader"
								click button "save" of window "Save"
								click button "Replace" of sheet 1 of window "save"
							end try
							try
								click button "OK" of window "Enable Usage Rights in Adobe Reader"
							end try
						end tell
					end tell
					close front document saving no
				end tell
			end repeat
		end if
	end repeat
end open


Thanks Stefan, that worked perfectly!