Skip to main content
Known Participant
November 18, 2023
Question

Script to open folder (directory) after PDF export

  • November 18, 2023
  • 2 replies
  • 786 views

Hi!
I'm working on a script that exports PDF documents into certain folders on my computer.
The code works like this: I open a file on an internet platform and it generates a temporary folder in my directory "C:\Users\eusou\Documents" and this folder has a variable name and changes every time I open the file via online platform. To get around this, I created a script that locates my PDF file in these folders with the same name as the indesign document file that I have open. So, I created a code so that it locates this folder, saves it in a variable and exports the file within this folder.
As there are many folders, I would like a script that opens the folder where it was exported after I export my file!

This topic has been closed for replies.

2 replies

Anantha Prabu G
Legend
November 18, 2023

Hi @eusoujpg 

 

You can use

var myFileLocation = Folder.selectDialog("Please select path to files"); // file path selection

 

Thanks,PrabuDesign smarter, faster, and bolder with InDesign scripting.
eusoujpgAuthor
Known Participant
November 18, 2023

O seu envio foi alterado porque um HTML inválido foi encontrado no corpo da mensagem. O HTML inválido foi removido. Reveja a mensagem e envie-a quando estiver satisfeito.

eusoujpgAuthor
Known Participant
November 18, 2023

Nothing specific. I would just like a code that opens the folder where my file was exported (of course, after the export process). It wouldn't be a specific folder. In your code, it asks for the folder location, however it is not specific.
(sorry, error in previous message)

 

m1b
Community Expert
Community Expert
November 18, 2023

Hi @eusoujpg, if you have the folder saved as a variable, as you say, and it is a Folder object, then you can do this:

// show the folder in explorer/finder
myFolder.execute();

 

If you have a document reference saved as a variable, you can do this to see the folder that contains it:

// show the folder that contains the document
myDoc.fullName.parent.execute();

 

If you use the execute method of Folder, it will reveal the folder's contents. If you use the execute method of File, it will open that file, like it would if you double-clicked it.

 

Does that cover what you needed?

- Mark