Copy link to clipboard
Copied
Hi,
How to define log report path, below code will generate the report on desktop path, but I want to generate log report on where my indesign file is opened. Can we do this by script. pls help me
This is for opening file:
var path = Folder.selectDialog ("Select folder");
var files = path.getFiles("*.indt" && "*.indt"),
myDoc = app.open(new File(files));
This is for output file:
var myTextFile = new File("~/Desktop/Log Report.csv")
myTextFile.open("w")
myTextFile.write("\nParagraph Style:")
myTextFile.write(myMissingParaStyle)
myTextFile.close();
by
hasvi
Hi Hasvi,
Replace it with : var files = path.getFiles(/\.(indd?|indt?)$/i );
Regards,
Chinna
Copy link to clipboard
Copied
Hi Hasvi,
Try this,
var myTextFile = new File(myDoc.filePath + "/LogReport.csv")
Regards,
Chinna
Copy link to clipboard
Copied
Hi Chinna,
It shows "Unsaved documents have no path" so want to save my input ("*.indt" && "*.indt")" file as a indd file with "New Indesign" this name, because my input indesign file may be 'indd' or 'indt'. pls help to save my file with name.
by
hasvi
Copy link to clipboard
Copied
Try this,
var path = Folder.selectDialog ("Select folder");
var files = path.getFiles("*.indt" && "*.indt");
myDoc = app.open(new File(files));
myDoc.save(new File(path + "/" + "New Indesign.indd"));
var myTextFile = new File(myDoc.filePath + "/LogReport.csv");
myTextFile.open("w")
myTextFile.write("\nParagraph Style:")
myTextFile.write(myMissingParaStyle)
myTextFile.close();
Regards,
Chinna
Copy link to clipboard
Copied
Hi chinna,
Many thanks. here 'var files = path.getFiles("*.indd" && "*.indt")' this code is correct or not because my folder have 'indt' file it works fine, but my folder have 'indd' file below error is shown,

And one more doubt, your code is shown 'myTextFile.close()' we have another code as like 'myTextFile.close(SaveOptions.SAVECHANGES)' what is the different between these.
by
hasvi
Copy link to clipboard
Copied
Hi Hasvi,
Try the below code. It will ask you to select a file not a folder.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var path = File.openDialog("Select file");
myDoc = app.open(new File(path));
myDoc.save(new File(path.toString().replace(myDoc.name, "New Indesign.indd")));
var myTextFile = new File(myDoc.filePath + "/LogReport.csv");
myTextFile.open("w")
myTextFile.write("\nParagraph Style:")
myTextFile.write(myMissingParaStyle)
myTextFile.close();
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
Regards,
Chinna
Copy link to clipboard
Copied
Hi chinna,
In below script I have changed library path file only, but its not running.
This code is working fine.
var doc = app.activeDocument;
var library=new File("C:\\Users\\Jayanthi\\Desktop\\test\\Library.indl");//Your library file path.
app.open(library);
asset = app.libraries[0].assets;
for(var i=0;i<asset.length;i++)
{
try{
doc.objectStyles.add({name:asset.name});
}
catch(e){}
}
This code is running but object style not created
function ObjectStyleCreation()
{
var library = path.getFiles("*.indl");
library=File(library);
if (!library.exists){
alert("Library File is Missing");
exit();}
else
{
app.open(library);
asset = app.libraries[0].assets;
for(var i=0;i<asset.length;i++)
{
try{
doc.objectStyles.add({name:asset.name});
}
catch(e){}
}
}
}
by
hasvi
Copy link to clipboard
Copied
Hi Hasvi,
Function 'ObjectStyleCreation()' hasn't been called anywhere in your script.
Regards,
Chinna
Copy link to clipboard
Copied
Hi chinna,
This is the full script, its running but object style not created.
var path = Folder.selectDialog ("Select folder");
var files = path.getFiles("*.indd" && "*.indt"),
myDoc = app.open(new File(files));
//~ app.activeDocument.save(path.fsName + "\\" + "NewIndesign"+".indd");
myDoc.save(new File(path + "/" + "New Indesign.indd"));
ObjectStyleCreation();
function ObjectStyleCreation()
{
var library = path.getFiles("*.indl");
library=File(library);
if (!library.exists){
alert("Library File is Missing");
exit();}
else
{
app.open(library);
asset = app.libraries[0].assets;
for(var i=0;i<asset.length;i++)
{
try{
doc.objectStyles.add({name:asset.name});
}
catch(e){}
}
}
}
by
hasvi
Copy link to clipboard
Copied
Replace doc with myDoc in the below line.
doc.objectStyles.add({name:asset.name});
Copy link to clipboard
Copied
thanks chinna,
Here my task is we want select folder only, that folder may have 'indd' or 'indt' any one file only that have.
here 'var files = path.getFiles("*.indd" && "*.indt")' this code is correct or not because my folder have 'indt' file it works fine, but my folder have 'indd' file not working.
by
hasvi
Copy link to clipboard
Copied
Hi Hasvi,
Replace it with : var files = path.getFiles(/\.(indd?|indt?)$/i );
Regards,
Chinna
Copy link to clipboard
Copied
Superb chinna
Copy link to clipboard
Copied
Hi chinna,
If am running the script again. already 'New Indesign.indd' file in that particular folder, how can we give the alert to message 'Already New Indesign.indd is there' and how can we override the file again the same path with 'New Indesign.indd' this name.
var path = Folder.selectDialog ("Select folder");
var files = path.getFiles(/\.(indd?|indt?)$/i );
myDocument = app.open(new File(files));
//~ app.activeDocument.save(path.fsName + "\\" + "NewIndesign"+".indd");
myDocument.save(new File(path + "/" + "New Indesign.indd"));
by
hasvi
Copy link to clipboard
Copied
Hi chinna,
here,
try
{
myDocument.save(new File(path + "/" + "New Indesign.indd"));
}
catch(e)
{
alert("A document already exists with the given name! Now its going to override");
}
alert("A document already exists with the given name! Now its going to override");
What is the process for do override the file with same name?
by
hasvi
Copy link to clipboard
Copied
Hi chinna,
I write code for override as like below, but its not working. pls help:
var path = Folder.selectDialog ("Select folder");
//~ var files = path.getFiles("*.indd" && "*.indt"),
var files = path.getFiles(/\.(indd?|indt?)$/i );
//~ app.activeDocument.save(path.fsName + "\\" + "NewIndesign"+".indd");
try
{
myDocument.save(new File(path + "/" + "New Indesign.indd"));
}
catch(e)
{
alert ("Already");
myDocument.override(new File(path + "/" + "New Indesign.indd"));
}
myDocument = app.open(new File(files));
by
hasvi
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more