How do I create a folder using ExtendScript?

拜拜、爱过 提交于 2019-12-05 02:01:45

问题


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

By the way, all searches online for the folderObj.create() method, which is in the JavaScript Tools Guide, prove useless. I've tried several variations on that method, but nothing seems to actually create the folder. What am I missing?


回答1:


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



回答2:


Okay, found a work-around: I have to specify the folder absolutely, rather than use the ~ home shortcut. In addition, I have 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 the resident ExtendScript expert around here.)




回答3:


try this:

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


来源:https://stackoverflow.com/questions/18339060/how-do-i-create-a-folder-using-extendscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!