Skip to main content
Inspiring
October 17, 2022
Answered

scan mask with name file and not extension

  • October 17, 2022
  • 1 reply
  • 241 views

hi into this function

var myFolder = Folder(defaultFolder).selectDlg("Select the folder containing InDesign Files");
//var myFolder = Folder.selectDialog("Select the folder containing InDesign Files", "");
if (!myFolder) exit();
var f = myFolder.getFiles(/\.(indd)$/i);
var doc;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
//Opens each ID file and runs the 
for (var i = 0; i < f.length; i++){
    doc = app.open(File(f[i]));
	doc.links.everyItem().update();
    OpenAndUpdate(doc);
}; 

 

 

i select a folder for scan all indd files

 

but i have so much files (1000 files),i want select only file with name "etiquette finie.indd"  (70 files)

 

 

thanks for you help

This topic has been closed for replies.
Correct answer Manan Joshi

Try the following code

function findAll (f, flist) 
{
    var f = Folder(f).getFiles("*.*");
    for (var i = 0; i < f.length; i++) 
    {
        if (f[i] instanceof Folder && f[i].name[0] != ".") 
            findAll (f[i], flist);
        else 
        {
            if(f[i].displayName == "etiquette finie.indd")
                flist.push(f[i])
        }
    }
}

var myFolder = Folder(defaultFolder).selectDlg("Select the folder containing InDesign Files");
//var myFolder = Folder.selectDialog("Select the folder containing InDesign Files", "");
if (!myFolder) exit();

var f = []
findAll(myFolder, f)
var doc;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
//Opens each ID file and runs the 
for (var i = 0; i < f.length; i++){
    doc = app.open(File(f[i]));
	doc.links.everyItem().update();
    OpenAndUpdate(doc);
};

-Manan

1 reply

Community Expert
October 17, 2022

Hi @laurence roussel12011930,

How can a single folder contain 70 files with the same name?

-Manan

-Manan
Inspiring
October 17, 2022

Nope it s in side different sub folder

Manan JoshiCommunity ExpertCorrect answer
Community Expert
October 17, 2022

Try the following code

function findAll (f, flist) 
{
    var f = Folder(f).getFiles("*.*");
    for (var i = 0; i < f.length; i++) 
    {
        if (f[i] instanceof Folder && f[i].name[0] != ".") 
            findAll (f[i], flist);
        else 
        {
            if(f[i].displayName == "etiquette finie.indd")
                flist.push(f[i])
        }
    }
}

var myFolder = Folder(defaultFolder).selectDlg("Select the folder containing InDesign Files");
//var myFolder = Folder.selectDialog("Select the folder containing InDesign Files", "");
if (!myFolder) exit();

var f = []
findAll(myFolder, f)
var doc;
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
//Opens each ID file and runs the 
for (var i = 0; i < f.length; i++){
    doc = app.open(File(f[i]));
	doc.links.everyItem().update();
    OpenAndUpdate(doc);
};

-Manan

-Manan