Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
12

Script to open folder (directory) after PDF export

Explorer ,
Nov 17, 2023 Nov 17, 2023

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!

TOPICS
Feature request , Import and export , Scripting
522
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2023 Nov 17, 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 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 17, 2023 Nov 17, 2023

Hi @eusoujpg 

 

You can use

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

 

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 18, 2023 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 18, 2023 Nov 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)

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 18, 2023 Nov 18, 2023
LATEST
var myDocument = app.activeDocument;
var myFilePath = myDocument.fullName;
if (myFilePath != "") {
    // Open the folder containing the exported file
    var folderPath = myFilePath.path;
    var folderFile = new File(folderPath);
    folderFile.execute();
} else {
    alert("Please save the document before running this script.");
}
Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines