How to create a folder using ExtendScript?

This seems to be a very simple problem, but I have been banging my head on it for almost an hour. All I need is a javascript / extendscript code snippet so that my InDesign CS6 script can create a folder. I know the existing folder in which a new one should be created, and I know the name that this new folder should call. But how do I get javascript for this?

By the way, all the Internet searches for the folderObj.create () method, which is located in the JavaScript tools manual, turned out to be useless. I tried several variations of this method, but nothing seems to actually create a folder. What am I missing?

+4
source share
3 answers

Well, I found a workaround: I need to specify the folder absolutely, and not use the ~ shortcut. In addition, I use /Volumes at the very beginning. Thus, the code becomes:

 var f = new Folder("/Volumes/apache HD/Users/apache/Desktop/my_new_fodler"); f.create(); 

And that seems to work, finally. Thanks for your help, @ Anna Forrest and @fabiantheblind! (You seem to be a resident ExtendScript expert here.)

+4
source
  var f = new Folder('/c/myfolder/'); if (!f.exists) f.create(); 
+14
source

try the following:

 var f = new Folder("~/Desktop/my_new_fodler"); f.create(); 
+3
source

Source: https://habr.com/ru/post/1498024/


All Articles