I have an Applescript script that I run as a batch against a photo editing app (Capture One). It is auto-generated by another app and creates smart collections out of a database of keywords. It is quite long and over time becomes longer and longer because more keywords are added from time to time. At the moment it’s about 50k lines and 5MB long. It’s quite slow to run (several hours), but this is another matter (in any case I run it overnight a few times per year). I’ve been running it without problems since a couple of years.
The script is basically an unrolled loop of about 3.600 iterations, each one does basically the same things over different data. It has grown quite a bit recently because I added a few lines to compute estimated completion time. Now it seems it never completes, because at a certain point (more or less 2/3 of the script, not always at the same point) a few strange error messages are printed on the console (an excerpt here):
Catalog 2024-11-23T00:57:01.192162Capture One got an error: Can’t make document into type integer.4-1700
make
group, Capture One got an error: Can’t make progress total units into type text., name, -1700
Catalog 2024-11-23T00:57:01.192162
«class prdt», Capture One got an error: Can’t make make into type text., kind, -1700
group
and shortly after a segmentation fault occurs. I believe there’s some sort of memory corruption, so the console output is meaningless. Inspecting the block of code where the script crashes shows no issues, and if I run the same script again the crash might happen a bit earlier or later, so I the code is not relevant.
The script is run by command line with osascript.
Is there any limitation to the lenght of an Applescript? Ideas? Workarounds? I anticipate that splitting the script or resuming from the point it stopped is not an easy option for me, for a number of reasons related to Capture One APIs.
Thanks.
PS I’ve said I don’t think code is relevant, anyway this is an iteration:
try
set progress text to "Importing: Workflow/workflow:published/workflow:published#twitter-weekly"
tell _workflow_published to make collection with properties {kind:smart album, name:"workflow:published#twitter-weekly", rules:"<?xml version=\"1.0\" encoding=\"UTF-8\"?><MatchOperator Kind=\"AND\"><Condition Enabled=\"YES\"><Key>IB_S_CONTENT_KEYWORDS</Key><Operator>6</Operator><Criterion>workflow:published#twitter-weekly</Criterion></Condition></MatchOperator>"}
set progress completed units to 3670
set ___elapsedtime to (current date) - ___basetime
set ___ct to ___elapsedtime * 0.000272
set ___completionTime to "" & (___ct div 60) & " minutes to complete"
set ___eta to time string of ((current date) + ___ct)
set progress additional text to "3670 / 3671 — 99% " & ___completionTime & " " & ___eta & ""
on error errorMessage number errorNumber
log "errorMessage: " & errorMessage & ", errorNumber: " & errorNumber
log ">>>> keyword: Workflow/workflow:published/workflow:published#twitter-weekly"
end try
