Open multiple indd docs through SDK

New Here ,
May 31, 2007 May 31, 2007

Copy link to clipboard

Copied

Hi guys
How can I open multiple indesign documents found in a folder chosen
through a folder chooser?
I need to open each indesign doc in that folder and do some
modification on each.
Here is what I have already written. Now how do I proceed please

SDKFolderChooser folderChooser;
folderChooser.SetTitle("Select folder where Indesign Docs are");
folderChooser.ShowDialog();
if (!folderChooser.IsChosen())
{
break; // cancelled
}

IDFile inFolder = folderChooser.GetIDFile();
PMString inFolderPath = folderChooser.GetPath();
if (inFolderPath.IsEmpty())
{
break;
}

//Now open loop through each file and do some processing on each one at a time

Logically I just have to loop through all the files in that folder,
open them and do my processing but I just cant find the right snippets
anywhere. I guess its pretty easy for u guys but am real new at that
and just cant find any examples anywhere.
Thanks for your help
Alicia
TOPICS
SDK

Views

1.2K

Likes

Translate

Translate

Report

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
New Here ,
May 31, 2007 May 31, 2007

Copy link to clipboard

Copied

Hi Alicia!

You can use the FileSystemIterator to go through all the files in a folder. See the paneltreeview sdk sample plug-in for example code for this.

Basically you probably want something like this:

PlatformFileSystemIterator iter;
iter.SetStartingPath(inFolderPath);

IDFile idFile;
PMString filter("\\*.indd");
bool16 hasNext = iter.FindFirstFile(idFile, filter);
SDKLayoutHelper helper;

if (FileUtils::DoesFileExist(idFile))
{
do
{
UIDRef docRef(helper.OpenDocument(idFile));
ASSERT(docRef);

helper.OpenLayoutWindow(docRef);

hasNext = iter.FindNextFile(idFile);
}
while (hasNext);
}

Good luck!

Oh, you need to include the actual implementations of PlatformFileSystemIterator and SDKLayoutHelper to your project so they are compiled into the plug-in, as they arent part of the InDesign runtime libs.

/Andreas

Likes

Translate

Translate

Report

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
New Here ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

Hi Andreas,
Thanks for pointing the way. I have added the PlatformFileSystemIterator.h into my project header files and have added the line #include "PlatformFileSystemIterator.h" in the cpp file but still am getting the error

fatal error C1083: Cannot open include file: 'PlatformFileSystemIterator.h': No such file or directory

Been struggling to resolve that in vain. Any idea where I went wrong or nay missing steps plz?

Thanks
Alicia

Likes

Translate

Translate

Report

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
New Here ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

i solved this include prob thanks.

Likes

Translate

Translate

Report

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
New Here ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

Thank you Andreas, It seems to work

Likes

Translate

Translate

Report

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
New Here ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

Hi Alicia!
Make sure you add also the WinFileSystemIterator.cpp (or MacFileSystemIterator.cpp if on Mac) source file provided by the SDK to your project.

Ciao
Emanuele

Likes

Translate

Translate

Report

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
New Here ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

Hi!

You also need to add the WinFileSystemIterator.cpp to your project.

/Andreas

Likes

Translate

Translate

Report

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
New Here ,
Jun 01, 2007 Jun 01, 2007

Copy link to clipboard

Copied

Hi Guys!

I'v seen this in WinFileSystemIterator.h

00086 // Not likely to be useful beyond a modest number
00087 enum {eMaxFolderItemsPerSingleIteration=256};

Does that mean that, if the folder contains more than 256 files those are skiped?

If so.
Is it OK if I change that number in order to get more files?

Thank you for your hints!

Likes

Translate

Translate

Report

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
New Here ,
Jun 04, 2007 Jun 04, 2007

Copy link to clipboard

Copied

Hi Andreas,

I have to import xml into multiple indd. The situation is like this

1. The user chooses the indd folder where all the indd doc are
2. The user chooses the xml folder where the xml for each indd is stored in subfolders bearing the name of the corresponding indd doc.
3. The plugin takes over and does the import of xml in corresponding indd.

I have used your code PlatformFileSystemIterator to open multiple Indd files but how do I achieve my second requirement?Am ok with the xml import, its just that I dont know which construct is to be used to get the files from the required subfolder of the root folder

Here is a little description of my code

// get the root folder of xml files
IDFile inFolder1 = folderChooser1.GetIDFile();
PMString inFolderPath1 = folderChooser1.GetPath();

//get the required subfolder in the root folder
// how to achieve that???

// Do the xml import
//ok with that

I hope you will be able to help me on that.
Thanks
Nadia

Likes

Translate

Translate

Report

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
New Here ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

Hi!

Which root-folder do you mean, the one of the indesign document, or the application, or the system root folder?

Take a look at the documentation for FileUtils. It provides functions for working with paths, such as AppendPath, which sounds like it may be of interest to you.

Something like:

PMString inFolderPath1 = folderChooser.GetPath();
FileUtils::AppendPath(&inFolderPath1, "xmlfiles");
FileUtils::AppendPath(&inFolderPath1, "myxmlfile.xml");


Good luck,
Andreas

Likes

Translate

Translate

Report

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
New Here ,
Jun 08, 2007 Jun 08, 2007

Copy link to clipboard

Copied

Hi Ervin,

you're right, the SDK-Iterator returns only the set value of files. I haven't tried inreasing the "eMaxFolderItemsPerSingleIteration" - from my experience you're probably better of implementing your own filesystem-iterator at that point. The SDK-Iterator is fine if you're certain that you're having few files/folders and beacause of it's cross-platform-approach - but to me it also seems to be rather slow.

Best regards,

Bernt

Likes

Translate

Translate

Report

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
New Here ,
Jun 11, 2007 Jun 11, 2007

Copy link to clipboard

Copied

You can safely increase that number but as Bernt said it would be much better if you modify that implementation in order to avoid setting any limit.

- mn

Likes

Translate

Translate

Report

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
New Here ,
Jun 15, 2007 Jun 15, 2007

Copy link to clipboard

Copied

Hi Bernt & Marco!

Thank you for your posts.

For the momment I'll try to encrease that number,

If I come to a better solution, I will post it.

Nice coding!

Likes

Translate

Translate

Report

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
Enthusiast ,
Apr 27, 2021 Apr 27, 2021

Copy link to clipboard

Copied

LATEST

In SDK 2021, PlatformFileSystemIterator is not found,

How can get list file Indesign in a folder?

Likes

Translate

Translate

Report

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