Skip to main content
Known Participant
July 31, 2025
Question

Add wait timer to While Loop - Automation Blocks

  • July 31, 2025
  • 2 replies
  • 278 views

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.

2 replies

GEditAuthor
Known Participant
July 31, 2025

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

ThioJoe
Community Expert
Community Expert
July 31, 2025

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.

 

Ivan Stepanov
Legend
August 2, 2025

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.

GEditAuthor
Known Participant
August 2, 2025

Good point, thank you!!

How could I solve this?