I’m trying to update my application to run under El Capitan, but have struck an error with code originally written by Shane Stanley, that now seems to error.
The code is beyond my knowledge, and Googling has not found an answer.
I’m trying to make sure I process a QuarkXPress project that does not have an extension.
on attachmentsPreparationOne()
try
set p to 1
set my ignoreGraphicConverterCount to false
set my printGraphicConverterCount to 0
set posixPath to POSIX path of (my holdingFolder)
if my RunForOz then tell application "System Events" to display dialog my holdingFolder as text # Displays with colon at end of path
set p to 2
set theTempList to my urlsInFolder:(posixPath) # Failing
set p to 3
set holdingFolderURL to current application's NSURL's fileURLWithPath:(posixPath)
set p to 3.1
if holdingFolderURL's lastPathComponent() as string = "Links" then
set p to 4
set parentURL to holdingFolderURL's URLByDeletingLastPathComponent()
set t to {}
set p to 5
set tAll to urlsInURL_(parentURL)
set p to 6
repeat with oneURL in tAll
if oneURL's pathExtension() as text = "indd" then
set end of t to oneURL
exit repeat
end if
end repeat
if (count of t) > 0 then set theTempList to {}
end if
on error errmsg number errnum
if errnum ≠ -1728 and my RunForOz then tell application "System Events" to display dialog "attachmentsPreparationOne First error " & errmsg & " number " & errnum & " p = " & p giving up after 40
end try
try
set p to 7
set fileManager to current application's NSFileManager's defaultManager() -- probably redundant at this stage
set my onlyPrintIndandQuarkflag to false
set p to 8
repeat with oneURL in theTempList -- list of URLs
set theExt to oneURL's pathExtension() as text
if theExt = "" then -- no extension
set p to 9
set {theFlag, theValue} to (oneURL's getResourceValue:(reference) forKey:(current application's NSURLLocalizedTypeDescriptionKey) |error|:(missing value)) -- get description
set theValue to theValue as text -- coerce to text
set p to 10
if theValue contains "QuarkXPress" then
tell fileManager to moveItemAtURL:(oneURL) toURL:(oneURL's URLByAppendingPathExtension:"qxp") |error|:(missing value)
set my onlyPrintIndandQuarkflag to true
else if theValue = "Rich Text Format (RTF)" then
tell fileManager to moveItemAtURL:(oneURL) toURL:(oneURL's URLByAppendingPathExtension:"rtf") |error|:(missing value)
else if theValue = "RTF with attachments (RTFD)" then
tell fileManager to moveItemAtURL:oneURL toURL:(oneURL's URLByAppendingPathExtension:"rtfd") |error|:(missing value)
else if theValue = "Unix Executable File" then
tell fileManager to moveItemAtURL:oneURL toURL:(oneURL's URLByAppendingPathExtension:"eps") |error|:(missing value)
else -- fall back to creator type
set attRecord to (fileManager's attributesOfItemAtPath:(oneURL's |path|()) |error|:(missing value)) as record -- returns a whole lot of stuff
set creatorType to NSFileHFSCreatorCode of attRecord -- returned as an integer; note pipes around path
if creatorType = 1.231963246E+9 then -- InDn as an integer
tell fileManager to moveItemAtURL:(oneURL) toURL:(oneURL's URLByAppendingPathExtension:"indd") |error|:(missing value)
set my onlyPrintIndandQuarkflag to true
else
if creatorType = 1.481658931E+9 then -- XPR3 as an integer
tell fileManager to moveItemAtURL:(oneURL) toURL:(oneURL's URLByAppendingPathExtension:"qxp") |error|:(missing value)
set my onlyPrintIndandQuarkflag to true
end if
end if
end if
else -- it has an extension
if theExt is in {"indd", "inx", "qxp", "qxd"} then
set my onlyPrintIndandQuarkflag to true
end if
end if
end repeat
on error errmsg number errnum
if errnum ≠ -1728 and my RunForOz then tell application "System Events" to display dialog "attachmentsPreparationOne error " & errmsg & " number " & errnum & " p = " & p giving up after 40
end try
my attachmentsPrintCycleOneInstallFonts() # as alias
end attachmentsPreparationOne