Loop Problem

I am getting confused on loops and how they work.

I want to loop until the number of files on the desktop change. While iMovie is exporting, there are x number of files on the desktop. After the export is complete, there are (x-1) files on the desktop. (This I have proved)

I want to sound an alarm when this happens. I’m trying to compare the before file number and the after file number in a loop, and then exit. I’ve tried Repeat, Until, and While. I’m getting loopy myself after working on this for a couple hours.

Please help. Thanks in advance.

BSF Loop.kmmacros (11.6 KB)

I haven’t tried to debug your macro but here is how I have approached the task of monitoring when the count of files has dropped.

First an Execute Shell Script action counts the number of files on the Desktop and saves the value in the variable local initial_count.

Then for each loop in an Until action, the macro pauses for the desired duration (in this demo, it is set to 1 second for test purposes only; you would want some multiple of 60 seconds, I presume) and then stores the current count of files in the variable local current_count.

The loop terminates when the current count is one less than the initial count.

iMovie export alarm..kmmacros (4.3 KB)

1 Like

Thank you. Very clean and neat.

1 Like

Don't forget that you can use a script in your loop's Condition. So:

2 Likes

Ah, I did wonder if there were sucn a feature but somehow I didn’t spot it. Perhaps I wasn’t optimistic enough to check carefully!

1 Like