Entfernen eins Passwortes von einem PDF-Dokument

Hallo!

Ich habe mich nun dazu entschlossen meine privaten Dokumente anstatt im Filesystem zu halten und nur in eine DTPO-Datebank zu verlinken vollständig in eine Datenbank zu schieben.

Bisher habe ich ein Folder-Script im Finder genutzt, um bei bestimmten PDF-Dateien das PDF-Passwort zu entfernen. Habe hierzu ein Script gebaut, das mit PDFTK arbeitet.
Nachdem ich jetzt diese Folder-Scripts in der Datenbank nicht mehr nutzen kann, kann mir jemand helfen dieses Script umzubauen?

----```

on adding folder items to theFolder after receiving theItems

-- enter your values here
set pdftkPosixPath to "/usr/local/bin/pdftk"
set pWord to "passowrd"
set appendedName to "_unlocked" -- text to append to the file name
set shouldTrash to true -- true or false, move the locked file to the trash after unlocking?

set fContainer to theFolder as text
repeat with anItem in theItems
	try
		tell application "System Events"
			set fName to name of anItem
			set fExt to name extension of anItem
		end tell
		
		if fExt is "pdf" and fName does not contain appendedName then
			set baseName to (text 1 thru -5 of fName) & appendedName & ".pdf"
			set newPath to fContainer & baseName
			do shell script (quoted form of pdftkPosixPath & space & quoted form of POSIX path of anItem & " input_pw " & quoted form of pWord & " output " & quoted form of POSIX path of newPath)
			
			if shouldTrash then
				tell application "Finder" to move anItem to trash
			end if
		end if
	end try
end repeat

end adding folder items to

----

Wäre echt super - Danke und liebe Grüße
Stefan

Erledigt… aber gerne nehme Tips wie das besser geht :wink:

-- Remove password from salery statement
try
	-- Get the selection
	tell application id "DNtp" to set thisSelection to the selection
	
	-- Error handling
	if thisSelection is {} then error localized string "Please select a document or group, then try again."
	if (length of thisSelection) > 1 then error localized string "Please select only one document or group, then try again."
	
	-- Get and format the data we need
	tell application id "DNtp"
		set thisItem to first item of thisSelection
	end tell
	
	performPwdRemoval(thisItem)
	
on error errmsg
	display alert (localized string "Error processing document " & thisItem)
end try


on performPwdRemoval(input)
	try
		set pp to path of input
		set n to text -5 thru 1 of pp
		set newfile to n & "_unlocked.pdf"
		
		-- enter your values here
		set pdftkPosixPath to "/usr/local/bin/pdftk"
		set pWord to "eyr63xrg"
		
		set scriptRemovePwd to quoted form of pdftkPosixPath & space & quoted form of POSIX path of pp & " input_pw " & quoted form of pWord & " output " & quoted form of POSIX path of newfile
		set scriptRename to "/bin/mv " & quoted form of POSIX path of newfile & space & quoted form of POSIX path of pp
		
		do shell script (scriptRemovePwd)
		do shell script (scriptRename)
		
		
	on error err
		log err
		display dialog err
	end try
	
	return input
end performPwdRemoval