PD_MetaDataInje

Hello,

if both files “ PDF_ToolPath, PDF_FilePath - are located on my boot volume, then this script works;
if both files reside on an USB stick, i get

error “ERROR: Could not write to file
/Volumes/Hama 16GB #2/pdPDF_MetaDataInjector Æ’/AppleScriptLanguageGuide 1996.pdf” number 1 from «script» to item


-- PDF_MetaDataInjector
-- based upon "inject metadata"
-- by Martin Michel · Administrator · Berlin, Germany · 2009-10-13 03:51:22 pm
-- http://macscripter.net/viewtopic.php?pid=187137

-- path to the pdfprops command line utility
property PDF_ToolPath : "/pdPDF_MetaDataInjector Æ’/pdfprops"
-- metadata to be injected
-- >> set a property value to «missing value» to ignore it
property Title : "AppleScript - The mutant language from the moon!"
property Author : "AS_LC_Group"
property Subject : "Problems & Solutions"
property Keywords : "A B C D E Z"
property Creator : "A wonderful Mac Enlightenment"
property PDF_FilePath : "/pdPDF_MetaDataInjector Æ’/AppleScriptLanguageGuide¢AS ??.7¢1996-???? #.pdf"

tell me
	activate
	set arguments to {}
	set PDF_ToolPath_Q to quoted form of POSIX path of PDF_ToolPath
	set PDF_FilePath_Q to quoted form of POSIX path of (PDF_FilePath as text)
	set keyvalues to {Author, Title, Subject, Creator, Keywords}
	set keynames to {" -author ", " -title ", " -subject ", " -creator ", " -keywords "}
	repeat with ii from 1 to 5
		set keyvalue to item ii of keyvalues
		if keyvalue is not missing value then
			set keyname to item ii of keynames
			set argument to keyname & quoted form of keyvalue
			set arguments to arguments & argument
		end if
	end repeat
	set command to PDF_ToolPath_Q & " -file " & PDF_FilePath_Q & arguments
	log command
	try
		do shell script command
	on error errmsg number errnum
		error errmsg number errnum
	end try
end tell

Thanks in advance

Peter

Model: MacPro 2012 ¢ OSX 10.11.6
AppleScript: 2.5
Browser: Safari 602.1.50
Operating System: Mac OS X (10.10)

Hi,

the problem is the property line PDF_ToolPath. You changed it compared to the original script.

Martin’s script uses missing value and assigns later an AppleScript alias specifier which is coerced to POSIX path. However a POSIX path coerced to POSIX path will cause unexpected behavior.

 set PDF_ToolPath_Q to quoted form of PDF_ToolPath

Hi, Stefan,

Thank you for your answer, but I can*t affirm . Whether or not the script runs on the boot or on another drive, the PDF_ToolPath (‘pdfprops’) is found.

Log of AppleScript on boot disk:

tell current application
	do shell script "'/pdPDF_MetaDataInjector Æ’/pdfprops' -file '/pdPDF_MetaDataInjector Æ’/AppleScriptLanguageGuide 1996.pdf' -author 'Martin Michel' -title 'AppleScript - The mutant language from the moon!' -creator 'A wonderful Mac application' -keywords 'Computer science,Apple,Macintosh'"
		--> ""
end tell
Ergebnis:
""

Log of AppleScript on other disk (here an USB stick):

tell current application
	do shell script "'/Volumes/Hama 16GB #2/pdPDF_MetaDataInjector Æ’/pdfprops' -file '/Volumes/Hama 16GB #2/pdPDF_MetaDataInjector Æ’/AppleScriptLanguageGuide 1996.pdf' -author 'Martin Michel' -title 'AppleScript - The mutant language from the moon!' -creator 'A wonderful Mac application' -keywords 'Computer science,Apple,Macintosh'"
		--> error "ERROR: Could not write to file
/Volumes/Hama 16GB #2/pdPDF_MetaDataInjector Æ’/AppleScriptLanguageGuide 1996.pdf" number 1
	activate
Ergebnis:
error "ERROR: Could not write to file
/Volumes/Hama 16GB #2/pdPDF_MetaDataInjector Æ’/AppleScriptLanguageGuide 1996.pdf" number 1 from «script» to item

Regards

Peter

Model: Model: MacPro 2012 ¢ OSX 10.11.6
AppleScript: 2.5
Browser: Safari 602.1.50
Operating System: Mac OS X (10.10)