Skip to main content
Known Participant
Jul 31, 2025 7:38 PM UTC
Question

Add wait timer to While Loop - Automation Blocks

Hey y'all,

 

I'm trying to figure out how to add a wait timer to my while loop in Automation Blocks.

I want it to wait 1 second before it executes again.

 

I need this for sync folders so it checks them to sync again every 1 second instead of hammering the system resources and syncing every nanosecond.

 

Any help or advice would be greatly appreciate to help me solve this.

 

If this is completely impossible then I ask the developers of Automation Blocks to please add this functionality.

4 replies

GEditAuthor
Known Participant
Jul 31, 2025 10:25 PM UTC

@ThioJoe thank you very much that is exactly what I was looking for! Much appreciated.

Translate
ThioJoe
Community Expert
Community Expert
Jul 31, 2025 9:28 PM UTC

Well the extendscript command to wait is:

$.sleep(1000);

Where 1000 can be any amount of milliseconds.

 

And while I'm not very familiar with Automation Blocks myself, it looks like you can run custom extendscript commands via the "Pr Other" option then put the above command into the 'execute code' field, like this:

 

Which you should be able to place into your existing while loop. 

 

Optionally if you want to simplify the look of it, since clicking "Pr Other" seems to add the variable stuff which isn't actually necessary here, it looks like you can click the gear on the block and select and delete the 'item' thing, which leaves just the execution part like this below.

 

Translate
Ivan Stepanov
Legend
Aug 2, 2025 1:31 PM UTC

I would be carefull with $.sleep() — ExtendScript engine is synchronous. It waits for a command to be executed and then proceeds to next task.

If you execute $.sleep(1000), it will block whole ExtenScript for 1 second, meaning no other extension will be able to access  it. You can check it easily, by trying to open Export tab (it also relies on ExtendScript): nothing will happen.

If you put sleep in forever loop it means ExtendScript will be occupied by your process forever.

Translate
GEditAuthor
Known Participant
Aug 2, 2025 3:24 PM UTC

Good point, thank you!!

How could I solve this?

Translate