Skip to main content
Inspiring
June 30, 2016
Question

Unable to create Folder -object in JS - only works in JSX

  • June 30, 2016
  • 1 reply
  • 1416 views

I'm making a Photoshop panel and I have a drop-down menu that I want to populate with elements based on the number of files in a folder. However, for reasons unknown to me I seem to be completely unable to create Folder-objects in the javascript file. I've tested the below three lines of code both in my JSX file and my JS file. In the JSX one it works as it should: I get an alert dialog printing out the temp/dummy name of the folder. In JS though the entire script comes to a halt after the row creating the folder. Why is this?

alert("trying to make folder...");

var lol = new Folder();

alert(lol);

This topic has been closed for replies.

1 reply

Pedro Cortez Marques
Legend
June 30, 2016

var FF=  Folder(Folder.desktop + "/myFolder");

if (!FF.exists) FF.create();

HeimdaalAuthor
Inspiring
June 30, 2016

Specifying a path changes nothing for me - the object is still not created, instead the code comes to a halt before the second alert. Also doing theFolder.create() does nothing either

EDIT: I even tried hardcoding the folder path and also make sure that the folder didn't exist already, but for reasons unknown the Folder-object is still not created.

fontAbsPath = "c:/Users/martin.dahlin/Desktop/Test/";

alert("trying to make folder... fontAbsPath is:\n" + fontAbsPath); // This is correct

var fontFolder = new Folder(fontAbsPath); // Script HALTS here! :(

if(!fontFolder.exists){

    alert("created folder because it didn't exist");

    fontFolder.create();

}else{

    alert("didn't create the folder because it already exists!");

}

DBarranca
Legend
July 6, 2016

The best person to help you may be id Davide Barranca:

Photoshop, etc. | Random thoughts on Photoshop, Coding and all the rest


Sorry for being late to the party, but the email linked to the AdobeID which I use to reply to Forum threads isn't active anymore and I really looove those green bars below my avatar

Heimdaal​, you can use the CEP "Other API" to deal with Files and Folders!

Please check here.

Regards,

Davide

---

Photoshop HTML Panels Development Course

http://htmlpanelsbook.com