Saving parent folder as entry

Is it possibile to save the active document parent folder subfolders like an entry array?
Thank you

Please define what is saving subfolders like an entry array

Create an instance of Folder class to use it with the folder.createFolder();

Do you mean getEntry()?

What does it have to do with an entry array? Please make your questions clear and specific. Also provide a piece of code what you already tried, what was the expected result and what exactly didn’t work or what errors you got.

Currently none of your created topics in the forum show you put any effort before asking questions. And even when you get specific solutions, it doesn’t look like you try to read and understand them, but rather just copy-pasting and expecting to work as is. That’s just showing a disrespect to other members of the community :frowning:

Please help others help you by showing that you did your research before asking

1 Like

I use this code, but doesn’t work:

var activeDocumentFilePath = app.activeDocument.path;
var parentFolderPath = activeDocumentFilePath.substring(0, activeDocumentFilePath.lastIndexOf("\\") + 1);
const testFolder = await parentFolderPath.createFolder("testfolder")

this code dosen’t work because parentFolderPath is a path and not an entry of path, i think

I already have the permanent token to the main folder where the activedocument file is nested inside a structure of folders.

I still don’t understand the problem. You have everything you need to make it work. Just get the entry from your token and continue from there. And I still have questions:

  1. Why did you expect it to work just with path string?
  2. What does this have to do with entry array?

Once I have the path difference, is there a direct way to access the found path or do I have to make a for loop?

  • You have your document path
  • You have your token folder path
  • Compare these paths and get the branch you need to get to the document from the token
  • Navigate to the document folder with getEntry() beginning from token folder
  • Create new folder in the document folder
1 Like

I use this code assuming that the difference between the two folder is “data\photos\original\”


token = await JSON.parse(localStorage.getItem("fixfolder"));
const permanentFolder = await fs.getEntryForPersistentToken(token);

/assuming the difference between the permanentFolder folder path and the active document folder path

tempFolder = permanentFolder.getEntry("data\\photos\\original\\");

const testfolder = await tempfolder.createFolder("testfolder");

this code doesn’t work, if i type tempFolder in the console return Promise= fullfilled

Can you help me? i think there is a little thing with i’m wrong wih

You need to await for the Promise

1 Like

Change the code with this and work :slight_smile:

token = await JSON.parse(localStorage.getItem("fixfolder"));
const permanentFolder = await fs.getEntryForPersistentToken(token);

/assuming the difference between the permanentFolder folder path and the active document folder path

tempFolder = await permanentFolder.getEntry("data\\photos\\original\\");

const testfolder = await tempfolder.createFolder("testfolder");

Thank you very much for the help to understaning the code