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

PNG creation with modified date

Guide ,
Jun 20, 2017 Jun 20, 2017

Copy link to clipboard

Copied

HI,

The following steps are doing.

1) Open two indesign files. One is source and another one is final file.

2) Based on modified date I need to create the png with file naming as _source and _final.

mains(); 

function mains() {     

    var docSou = app.documents[0];

    var docFin = app.documents[1];

    var SouName = File(docSou.fullName);  

    var FinName = File(docFin.fullName); 

    var modifiedDate1= SouName.modified; 

    var modifiedDate2= FinName.modified; 

   

    mycheck1();

   

    function mycheck1(){

        if(modifiedDate1<modifiedDate2){

            var docName =docSou.name.replace(/\.[^\.]+$/, '_source');

            set_png_export_options(); 

            var file = new File("~/Desktop"+"/"+docName+".png");             

            docSou.exportFile(ExportFormat.PNG_FORMAT, file); 

            mycheck2();

            exit();

        }

        else{

            var docName =docFin.name.replace(/\.[^\.]+$/, '_final');

            set_png_export_options(); 

            var file = new File("~/Desktop"+"/"+docName+".png"); 

            docFin.exportFile(ExportFormat.PNG_FORMAT, file); 

            mycheck3();

            exit();

        }

    }

function mycheck2(){

    var docName =docFin.name.replace(/\.[^\.]+$/, '_final');

    var file = new File("~/Desktop"+"/"+docName+".png"); 

    docFin.exportFile(ExportFormat.PNG_FORMAT, file); 

    }

function mycheck3(){

    var docName =docSou.name.replace(/\.[^\.]+$/, '_source');

    var file = new File("~/Desktop"+"/"+docName+".png");             

    docSou.exportFile(ExportFormat.PNG_FORMAT, file); 

    }

 

function set_png_export_options() { 

    with(app.pngExportPreferences) { 

        antiAlias = true; 

        embedColorProfile = true; 

        exportResolution =  1600; 

        exportingSpread = true; 

        PNGColorSpace = PNGColorSpaceEnum.RGB; 

        PNGExportRange = PNGExportRangeEnum.EXPORT_ALL; 

        PNGQuality = PNGQualityEnum.MAXIMUM; 

        simulateOverprint = false; 

        transparentBackground = false; 

        useDocumentBleeds = true; 

    } 

  

But it always show the first document as _source.

Could you please suggest where I am missing.

Regards,

K

TOPICS
Scripting

Views

1.6K

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
Guide ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

Hi,

Any suggestion please, I know I am very close to the solution, but not able to find out that!!

Thanks,

K

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
Engaged ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

I am not sure what you are trying to achieve.

But I am wondering why you are exporting twice.

In the function mycheck1:

Inside IF you export to file with "_source" name.

Also you call mycheck2() which exports to file with "_final" name.

Same in the else block also.

So, essentially you seem to overwrite the file.

Please check if you intend to do so.

I believe with some traces you should be able to figure out.

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
Guide ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

Hi,

Thanks for your reply. If you see the first code, I am taking two indesign file. One is source and another one is final file. So I am exporting twice. So i not overriding.

Thanks,

K

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
Engaged ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

As I see the following code,

var docSou = app.documents[0];  

var docFin = app.documents[1]; 

docSou.name.replace(/\.[^\.]+$/, '_source');

docFin.name.replace(/\.[^\.]+$/, '_final'); 

Whether it is the IF or the ELSE that is executing:

The first document is always tagged as "_source"

The second document as "_final"

Did you intend to do so above?

Or did you intend to switch the source and dest doc as per modified file, which seems missing.

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
Guide ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

Ye, but am taking the modifiedDate for each document and checking whether first document is old or not. If it is old means it tagged as source then it go to the mycheck2() function. This function will give the second document as Final.

I am not sure I am explained clearly

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
Guide ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

I found the mistake I did.. here is final script working good..

mains();  

function mains() {      

    var docSou = app.documents[0];

    var docFin = app.documents[1];

    var SouName = File(docSou.fullName);  

    var FinName = File(docFin.fullName);  

    var modifiedDate1= SouName.modified;  

    var modifiedDate2= FinName.modified;  

    

    mycheck1();

    

    function mycheck1(){

        if(modifiedDate1<modifiedDate2){

            var docName =docSou.name.replace(/\.[^\.]+$/, '_source');

            set_png_export_options();  

            var file = new File("~/Desktop"+"/"+docName+".png");              

            docSou.exportFile(ExportFormat.PNG_FORMAT, file);  

            mycheck2();

            exit();

        }

        else{

            var docName =docSou.name.replace(/\.[^\.]+$/, '_final');

            set_png_export_options();  

            var file = new File("~/Desktop"+"/"+docName+".png");  

            docSou.exportFile(ExportFormat.PNG_FORMAT, file);  

            mycheck3();

            exit();

        }

    }

function mycheck2(){

    var docName =docFin.name.replace(/\.[^\.]+$/, '_final');

    var file = new File("~/Desktop"+"/"+docName+".png");  

    docFin.exportFile(ExportFormat.PNG_FORMAT, file);  

    }

function mycheck3(){

    var docName =docFin.name.replace(/\.[^\.]+$/, '_source');

    var file = new File("~/Desktop"+"/"+docName+".png");              

    docFin.exportFile(ExportFormat.PNG_FORMAT, file);  

    }

}  

  

function set_png_export_options() {  

    with(app.pngExportPreferences) {  

        antiAlias = true;  

        embedColorProfile = true;  

        exportResolution =  1600;  

        exportingSpread = true;  

        PNGColorSpace = PNGColorSpaceEnum.RGB;  

        PNGExportRange = PNGExportRangeEnum.EXPORT_ALL;  

        PNGQuality = PNGQualityEnum.MAXIMUM;  

        simulateOverprint = false;  

        transparentBackground = false;  

        useDocumentBleeds = true;  

    }  

}  

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
Guide ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

Thanks for interest vinothr

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
Engaged ,
Jun 21, 2017 Jun 21, 2017

Copy link to clipboard

Copied

LATEST

That is what I meant. You didn't swap the source and final, which you have done now (in ELSE block):

var docName =docFin.name.replace(/\.[^\.]+$/, '_final'); 

TO

var docName =docSou.name.replace(/\.[^\.]+$/, '_final');

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