#applescript
#applescript
Вопрос:
Я только что обновился до Catalina, и один из моих applescripts больше не работает. Интересно, есть ли у кого-нибудь идеи относительно того, почему? Все выбранные папки (одиночные или пакетные) находятся на рабочем сервере. Результат, который я получаю из редактора сценариев после выбора папки:
— ошибка ‘ascr» ‘{ ‘—-‘:’ utxt'(«Не удается преобразовать, не удается преобразовать некоторый объект в тип some object.»), ‘errn’:-1700, ‘erob’:’alis'(«file:///System/Volumes/Data/data/ARLSCAN2/DIGI/ORIG/FRETSCHEL/Auto /DONE /F2509») }
--Script Name:
set ScriptName to "jhoveValidation"
--Define user name
set userName to do shell script "whoami"
--Initalize ErrorCount
set errorCount to 0
--Initalize stampCount
set stampCount to 0
-- BEGIN SCRIPT!
--Option to change location mode
set locationModeChoice to display dialog "Would you like to check a single box folder or batch check a directory of box folders?" buttons ["Exit", "Single", "Batch"] default button 3 with title ScriptName with icon caution
set locationModeChoice to button returned of locationModeChoice
if locationModeChoice = "Exit" then
return
end if
if locationModeChoice = "Single" then
set imageDirectory to choose folder with prompt "Select Single Box Folder"
else if locationModeChoice = "Batch" then
set customFolder to choose folder with prompt "Please select a folder of box folders with standard ICT hierarchy:"
set masterFolder to customFolder
end if
-- BEGIN PREFLIGHT
--Populates list of files in finder
set progress description to "jhoveValidation"
set progress additional description to "Loading box and file information..."
set progress total steps to -1
delay 1
if locationModeChoice = "Batch" then
tell application "Finder"
set masterList to folders in masterFolder
if (count of items in masterList) is 0 then
display dialog "ERROR: No files were detected" buttons ["Quit"]
return
end if
end tell
else if locationModeChoice = "Single" then
set masterList to {}
set masterList to masterList amp; imageDirectory
end if
-- BEGIN IMAGE PROCESSING
set folderCount to count masterList
set folderCounter to 1
repeat with aFolder in masterList
set currentWorkingBox to getLastPathItem(aFolder)
tell application "Finder"
try
set inputFolder to (every folder in aFolder whose name begins with "TIFF") as alias
on error
display dialog "There was an error finding your TIFF folder for box:
" amp; currentWorkingBox amp; "
Please place the images you want to inspect in a completed box folder with a TIFF folder inside." buttons ["Quit"]
return
end try
end tell
set progress description to (currentWorkingBox as text) amp; ": jhoveValidation - Box " amp; folderCounter amp; " of " amp; folderCount
set progress additional description to "Loading TIFF files..."
set progress total steps to -1
tell application "Finder"
try
set filesList to files in inputFolder
set filesCount to count filesList
on error
display dialog "There was an error finding your TIFF folder for box:
" amp; currentWorkingBox amp; "
Please place the images you want to inspect in a completed box folder with a TIFF folder inside." buttons ["Quit"]
return
end try
end tell
--***BEGIN LOOP***
--Individual file processing begins here
set loggingCounter to 0
set totalSteps to count filesList
set progress total steps to totalSteps
repeat with aFile in filesList
set loggingCounter to loggingCounter 1
log loggingCounter
set progress additional description to "Processing file " amp; loggingCounter amp; " of " amp; totalSteps
set progress completed steps to loggingCounter
set AppleScript's text item delimiters to "."
if (the last text item of (aFile as text) is "tif") then
tell application "Finder"
set theFile to aFile as alias
set theFilePath to POSIX path of theFile
log theFilePath
end tell
do shell script "cd ~/Desktop/jhove; ./jhove -c conf/jhove.conf -l SEVERE -o " amp; (theFilePath as text) amp; ".txt -m TIFF-hul " amp; theFilePath
else
end if
end repeat
set progress additional description to "Processing Results amp; Generating Reports..."
set progress total steps to -1
set currentWorkingFolderPath to POSIX path of (aFolder as alias)
try
do shell script "mkdir " amp; currentWorkingFolderPath amp; "VALIDATION"
end try
do shell script "mv " amp; currentWorkingFolderPath amp; "TIFF/*.txt " amp; currentWorkingFolderPath amp; "VALIDATION"
do shell script "grep -H 'Status' " amp; currentWorkingFolderPath amp; "VALIDATION/*.txt | sed 's/:/,/' > " amp; currentWorkingFolderPath amp; "VALIDATION/results.csv"
set theResults to {}
set theResults to theResults amp; paragraphs of (do shell script "cat " amp; currentWorkingFolderPath amp; "VALIDATION/results.csv")
set resultsCount to count theResults
set rejectList to {}
set reportStatus to "PASS"
set passCounter to 0
set failCounter to 0
repeat with aResult in theResults
set AppleScript's text item delimiters to ","
log text item 2 of aResult
set thisVar to text item 2 of aResult
if (text item 2 of aResult as text) = " Status: Well-Formed and valid" then
set passCounter to passCounter 1
log "PASS"
else
set failCounter to failCounter 1
set rejectList to rejectList amp; aResult
set reportStatus to "FAIL"
log "FAIL"
end if
end repeat
set totalCount to passCounter failCounter
if reportStatus = "PASS" then
do shell script "echo "All files have passed JHOVE Validation." > " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo " " >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo "" amp; passCounter amp; " files were validated." >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo " " >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "date >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
else
do shell script "echo "!!! ATTENTION - some files have failed JHOVE Validation!!! " > " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo "" amp; passCounter amp; " files passed." >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo "" amp; failCounter amp; " files failed." >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo " " >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo "----- " >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo "The following have reported failed JHOVE Validation: " >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
repeat with aReject in rejectList
do shell script "echo "" amp; aReject amp; "" >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
end repeat
do shell script "echo " " >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "echo "----- " >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
do shell script "date >> " amp; currentWorkingFolderPath amp; "jhoveReport.txt"
end if
set folderCounter to folderCounter 1
end repeat
--***END LOOP***
-- END SCRIPT
-- Function: Returns the document name without extension (if present)
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
if (item idx of fName = ".") then
set baseName to (items 1 thru (idx - 1) of fName) as string
end if
end repeat
return baseName
end getBaseName
on getLastPathItem(thePathToParse)
set thePathToParse to (thePathToParse as text)
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set lastPathLength to the number of text items in thePathToParse
set lastPathTarget to lastPathLength - 1
set the lastPathItemItem to text item lastPathTarget of thePathToParse
set AppleScript's text item delimiters to oldDelims
return lastPathItemItem
end getLastPathItem
on getLastPathItemFile(thePathToParse)
set thePathToParse to (thePathToParse as text)
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set the lastPathItemItem to the last text item of thePathToParse
set AppleScript's text item delimiters to oldDelims
return lastPathItemItem
end getLastPathItemFile
Комментарии:
1. С тех пор я протестировал это с локальной папкой, и я могу продолжить, но в итоге я получаю сообщение об ошибке «Отсутствует среда выполнения Java, запрашивающая установку». номер 1″.
2. Установлена ли у вас самая последняя версия Java? macOS перестала упаковывать его много лет назад, поэтому вам придется загружать его вручную; установка новой ОС могла удалить или отключить его.
3. Привет, @TedWrigley! ДА. В настоящее время я использую последнюю версию Java.