Skip to main content
RockScript
Known Participant
June 5, 2009
Answered

How to open indesign files and close

  • June 5, 2009
  • 1 reply
  • 1031 views

i want to open indesgin files exist in the folder and i want to open all the files one by one and i want to close wht are the files i opened

could anyone tell me.

This topic has been closed for replies.
Correct answer Jongware

You might want to be more explicit.

I inserted the "Close [Y/N]" because without that prompt, the script would do exactly what you ask: open all files and close them again. Not very exciting, but if that's what you need, just remove the line 12 "if (confirm ("Close "+str) == true)".

1 reply

Jongware
Community Expert
Community Expert
June 5, 2009

The following script does exactly that.

var fileLocation = Folder.selectDialog("Select a folder");
folder = new Folder ([fileLocation]);
folderContents = folder.getFiles("*.indd");
var openedFiles = new Array;
var filenames = new Array;
for (i=0; i<folderContents.length; i++)
{
filenames.push (folderContents+"\n");
openedFiles.push(app.open (folderContents));
}
str = filenames.join();
if (confirm ("Close "+str) == true)
for (i=0; i<openedFiles.length; i++)
  openedFiles.close();

As you can see, you are responsible yourself  for keeping a list of the files you opened. But with that list, you can do some interesting stuff -- such as closing the same files again.

RockScript
Known Participant
June 5, 2009

if i select my indesign file folder it showing close(y or n). but i want to open all the files(4) in the folder. could u tell me. i want to open all the files

through script and i want to close all the opened files

Jongware
Community Expert
JongwareCommunity ExpertCorrect answer
Community Expert
June 5, 2009

You might want to be more explicit.

I inserted the "Close [Y/N]" because without that prompt, the script would do exactly what you ask: open all files and close them again. Not very exciting, but if that's what you need, just remove the line 12 "if (confirm ("Close "+str) == true)".