Should all the copying/moving be done in AppleScript?
Or can I use KMs built in copy/moving actions?
Progress bar updates are made inside a scripting loop, so the vanilla route is for that loop to contain two parts:
- Do something to the next batch of lines ( file paths for example )
- Update the progress bar
In Javascript, for example, it might look a bit like this:
// INNER LOOP: EXECUTE AND REPORT IN BATCHES
for (var i = 0; i < lngReports; i++) {
// GET THE NEXT SET OF LINES
lngStart = i * lngBatch;
lngEnd = lngStart + lngBatch;
lstBatch = lstLines.slice(lngStart, lngEnd);
strBatch = lstBatch.join('\n');
if (strBatch) {
// 1. DO SOMETHING WITH THIS BATCH OF LINES
copyFilesByPathName(strBatch, strTarget);
// 2. AND REPORT ON NUMBER OF LINES DEALT WITH SO FAR
Progress.description = (lngEnd + " of " + lngLines);
Progress.additionalDescription = lstLines[lngEnd];
Progress.completedUnitCount = lngEnd;
}
}
Of course, we can call a macro from inside a script loop, so I did experiment with sketching a plugin which:
- Takes the name of a macro,
- the name of the variable which that macro reads and works on,
- and the number (N) of progress bar updates that we want (more is fun, but slows the process)
and then feeds lines in N batches from another variable or clipboard to the one which the macro reads, updating the progress bar after each mouthful that has been fed to the client macro.
For example, if you began by creating or installing a very simple test macro which reads a variable called set of lines,
Read some lines aloud.kmmacros (1.2 KB)
You could then either use it on its own (without a progress bar),
or call it from the experimental plugin at: Displaying a progress bar as a macro works through a collection of lines
It's just an experiment – I'm not sure which approach is really simpler: doing the work inside the script, or using the plugin : - )