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

How to define log report path

Participant ,
Jun 10, 2014 Jun 10, 2014

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

TOPICS
Scripting
1.3K
Translate
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

Enthusiast , Jun 10, 2014 Jun 10, 2014

Hi Hasvi,

Replace it with : var files = path.getFiles(/\.(indd?|indt?)$/i );

Regards,

Chinna

Translate
Enthusiast ,
Jun 10, 2014 Jun 10, 2014

Hi Hasvi,


Try this,


var myTextFile = new File(myDoc.filePath + "/LogReport.csv")


Regards,

Chinna

Translate
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
Participant ,
Jun 10, 2014 Jun 10, 2014

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

Translate
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 ,
Jun 10, 2014 Jun 10, 2014

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

Translate
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
Participant ,
Jun 10, 2014 Jun 10, 2014

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,

1.png

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

Translate
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 ,
Jun 10, 2014 Jun 10, 2014

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

Translate
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
Participant ,
Jun 10, 2014 Jun 10, 2014

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

Translate
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 ,
Jun 10, 2014 Jun 10, 2014

Hi Hasvi,

Function 'ObjectStyleCreation()' hasn't been called anywhere in your script.

Regards,

Chinna

Translate
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
Participant ,
Jun 10, 2014 Jun 10, 2014

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

Translate
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 ,
Jun 10, 2014 Jun 10, 2014

Replace doc with myDoc in the below line.

doc.objectStyles.add({name:asset.name});

Translate
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
Participant ,
Jun 10, 2014 Jun 10, 2014

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

Translate
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 ,
Jun 10, 2014 Jun 10, 2014

Hi Hasvi,

Replace it with : var files = path.getFiles(/\.(indd?|indt?)$/i );

Regards,

Chinna

Translate
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
Participant ,
Jun 10, 2014 Jun 10, 2014

Superb chinna

Translate
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
Participant ,
Jun 11, 2014 Jun 11, 2014

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

Translate
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
Participant ,
Jun 11, 2014 Jun 11, 2014

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

Translate
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
Participant ,
Jun 11, 2014 Jun 11, 2014
LATEST

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

Translate
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