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

Open all indd files from selected folder and its sub-folders

Contributor ,
May 15, 2024 May 15, 2024

Copy link to clipboard

Copied

Hi all! 🙂

I have found this script written by @Kasyan Servetsky on an old post, and it's exactly what I need. However, somehow it's not working for me. When I select the folder, I get this message "Found no InDesign documents" even if there are indd files in the folder and its sub-folders. Could anyone have a look please? Thanks in advance!

var files;

var folder = Folder.selectDialog("Select a folder with InDesign documents");

if (folder != null) {

    files = GetFiles(folder);

    if (files.length > 0) {

        // turn off warnings: missing fonts, links, etc.

        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

        for (i = 0; i < files.length; i++) {

            app.open(files);

        }

        // turn on warnings

        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

    }

    else {

        alert("Found no InDesign documents");

    }

}

function GetFiles(theFolder) {

    var files = [],

    fileList = theFolder.getFiles(),

    i, file;

    for (i = 0; i < fileList.length; i++) {

        file = fileList;

        if (file instanceof Folder) {

            files = files.concat(GetFiles(file));

        }

        else if (file instanceof File && file.name.match(/\.indd$/i)) {

            files.push(file);

        }

    }

    return files;

}

 

TOPICS
Scripting

Views

215

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

correct answers 1 Correct answer

Guru , May 17, 2024 May 17, 2024

Sorry! Here's a mistake: 

file = fileList[0];
var files;
var folder = Folder.selectDialog("Select a folder with InDesign documents");
if (folder != null) {
	files = GetFiles(folder);
	if (files.length > 0) {
		// turn off warnings: missing fonts, links, etc.
		app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
		for (i = 0; i < files.length; i++) {
			app.open(files);
		}
		// turn on warnings
		app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTE
...

Votes

Translate

Translate
Guru ,
May 17, 2024 May 17, 2024

Copy link to clipboard

Copied

LATEST

Sorry! Here's a mistake: 

file = fileList[0];
var files;
var folder = Folder.selectDialog("Select a folder with InDesign documents");
if (folder != null) {
	files = GetFiles(folder);
	if (files.length > 0) {
		// turn off warnings: missing fonts, links, etc.
		app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
		for (i = 0; i < files.length; i++) {
			app.open(files);
		}
		// turn on warnings
		app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
	}
	else {
		alert("Found no InDesign documents");
	}
}
function GetFiles(theFolder) {
	var files = [],
	fileList = theFolder.getFiles(),
	i, file;
	for (i = 0; i < fileList.length; i++) {
		file = fileList[0];
		if (file instanceof Folder) {
			files = files.concat(GetFiles(file));
		}
		else if (file instanceof File && file.name.match(/\.indd$/i)) {
			files.push(file);
		}
	}
	return files;
}

Also, check out my batch processor script.

— Kas

Votes

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