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

[ExtendScript Bug] Folder.create() may no longer work on macOS/InDesign 20.1

Guide ,
Jan 28, 2025 Jan 28, 2025

Hi people,

 

Until today and on all platforms, the low-level ExtendScript method Folder.prototype.create() was able to create a full path of non-existent subfolders within some root folder. For example, with the code

 

   var myFolder = new Folder( Folder.myDocuments + '/dir1/dir2/dir3' );

   myFolder.create();

 

you were obtaining the creation of all required subfolders (dir1, dir2, dir3) in case of non-existence. This behavior was consistent across all versions of ExtendScript that we knew of, and on all systems.

 

As of InDesign 20.1 (not 20.0.x), and specifically on macOS, the above code will not always produce the desired result. In fact, only the dir1 folder will be created (if it does not exist), or only dir2 (if dir1 exists but not dir2), and so on. In other words, myFolder.create() only creates the highest missing folder in the hierarchy—so it will only work correctly if all parent folders were already existing.

 

A particular side effect is that, even if no errors are reported during the operation, a successfull myFolder.create() does not guarantee that myFolder.exists is then true!

 

It's easy to imagine countless scenarios where this change (which in my opinion is a pure bug) will significantly affect the behavior of your scripts, including those already in circulation.

 

Until Adobe fixes this issue or provides us with more details, it is possible to ‘patch’ the faulty method and restore its consistency. I just implemented this fix in the IdExtenso framework, but since I know that an infinitesimal number of developers use it, here the basic solution I suggest to you:

 

//==========================================================================
// [FIX250129] Folder.prototype.create()
// Fixes the Folder creation bug in macOS + ID 20.1
//==========================================================================

if( 'Macintosh'==File.fs && 20.1 <= parseFloat(app.version) )
//----------------------------------
// Provides a patch to the method `Folder.prototype.create` so
// that it still creates the folder including all missing parents
// at the location given by the path property. Returns true if the
// folder was created successfully.
{
   // Backup original method.
   Folder.prototype.__create__ = Folder.prototype.create;

   // Patch.
   Folder.prototype.create = function create()
   {
      return this.exists ||
      (
         ( null===this.parent || this.parent.create() )
         && this.__create__()
      );
   };
}

 

Hope that helps.

 

Best,

Marc

TOPICS
Scripting
380
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

correct answers 2 Correct answers

Adobe Employee , Feb 20, 2025 Feb 20, 2025

Hi,
Thank you for reporting the issue. We have been able to reproduce the issue and it is currently under investigation. 

Adobe InDesign Team

Translate
Adobe Employee , Mar 04, 2025 Mar 04, 2025

@Js1212 

The fix for this issue is available in the InDesign PreRelease build(v20.2.0.036) and above.
Please check if the issue is now resolved.

Download/Update the latest InDesign PreRelease build in Creative Cloud under the “Prerelease” category(Refer to “Prerelease_CreativeCloud.png” for reference)

Prerelease_CreativeCloud.pngexpand image
Please apply to the InDesign PreRelease in case you don’t have access to the InDesign PreRelease build – https://www.adobeprerelease.com/beta/C6DFA254-C40C-4EEB-8F6D-F4AEDA2E6171

If you still encoun

...
Translate
Community Expert ,
Jan 28, 2025 Jan 28, 2025

Does it work recurently? Will this piece of code create all subfolders? 

 

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 ,
Feb 19, 2025 Feb 19, 2025

Hi @Robert at ID-Tasker, yes it recurses. Here:

 

this.parent.create()

 

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 ,
Jan 28, 2025 Jan 28, 2025

Hi @Marc Autret I noticed my scripts failing, too, but hadn't had time to look into it. Thanks for posting here as well as a nice workaround! Is there a bug report to vote on?

- Mark

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
People's Champ ,
Jan 29, 2025 Jan 29, 2025

Insane code as always!

Thanks Marc.

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 ,
Feb 19, 2025 Feb 19, 2025

Hi all, for what it's worth, I've created a bug report on uservoice. Please vote!

- Mark

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
Adobe Employee ,
Feb 20, 2025 Feb 20, 2025

Hi,
Thank you for reporting the issue. We have been able to reproduce the issue and it is currently under investigation. 

Adobe InDesign Team

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 ,
Mar 04, 2025 Mar 04, 2025

thank you....been going nuts trying to solve!!!!!

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
Adobe Employee ,
Mar 04, 2025 Mar 04, 2025

@Js1212 

The fix for this issue is available in the InDesign PreRelease build(v20.2.0.036) and above.
Please check if the issue is now resolved.

Download/Update the latest InDesign PreRelease build in Creative Cloud under the “Prerelease” category(Refer to “Prerelease_CreativeCloud.png” for reference)

Prerelease_CreativeCloud.pngexpand image
Please apply to the InDesign PreRelease in case you don’t have access to the InDesign PreRelease build – https://www.adobeprerelease.com/beta/C6DFA254-C40C-4EEB-8F6D-F4AEDA2E6171

If you still encounter any issues, please drop a mail to sharewithID@adobe.com.


Adobe InDesign team

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 ,
Mar 05, 2025 Mar 05, 2025
LATEST

@Sanyam Talwar thank you! I can confirm on MacOS 15.3.1, ID 20.2 the bug is fixed!

- Mark

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