Skip to main content
Known Participant
July 7, 2023
Question

Using Script to Create sub-folder using variable as name - need help

  • July 7, 2023
  • 2 replies
  • 488 views

I have an image in folder in download\TEST, I want create a new sub-folder in test and save image to it

var myDocument = activeDocument;
var f = new Folder(myDocument.path+theResult.join("X"))

if (!f.exists) {

    f.create();

theResult.join("X") is a variable stored values from another function whitch is 2X3, above code created folder

download\TEST2X3 instead download\TEST\2x3 (result I want)

 

How to fix it ? thank you

 

 

 

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
July 7, 2023

@Calvin21914323wi10 – Untested, but perhaps:

 

var f = new Folder(myDocument.path+"/"+theResult.join("X"));

 

Or:

 

var f = new Folder(myDocument.path+"\\"+theResult.join("X"));

 

Known Participant
July 8, 2023

Second one, works, thank ou very much

Stephen Marsh
Community Expert
Community Expert
July 8, 2023

@Calvin21914323wi10 - Thanks for the feedback, please mark my previous reply as the correct answer. I would have thought that both versions would have resulted in a valid directory separator being added.

Sef McCullough
Community Expert
Community Expert
July 7, 2023

@Calvin21914323wi10 I'm gonna put money down that @Stephen Marsh is the guy to help you with this one!

Stephen Marsh
Community Expert
Community Expert
July 7, 2023

@Sef McCullough – thanks, no pressure! 

 

There are many scripters here who I believe can also help...