Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add wait timer to While Loop - Automation Blocks

Explorer ,
Jul 31, 2025 Jul 31, 2025

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.

TOPICS
SDK
313
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2025 Jul 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:

ThioJoe_0-1753997144855.png

 

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.

ThioJoe_1-1753997287007.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 02, 2025 Aug 02, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2025 Aug 02, 2025
LATEST

Good point, thank you!!

How could I solve this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 31, 2025 Jul 31, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines