2 Replies Latest reply on Jan 17, 2012 7:57 PM by twintern20

    [js][cs4] How do I access a link modified date using a script

    twintern20

      When I interactive check a link's Info, the modified date is Tuesday, January 17, 2012 7:18 but my script returns the date the link was last updated instead of the file's date. For instance it may be yesterday's date even though the file was updated a few minutes ago.

       

      I've tried docRef.links[i].linkXmp.properties.modificationDate and docRef.links[i].date but I can't seem to check the link's file date.

       

      I was able to get the date using vb script but I'm wanting to use JSON to information to re-link to different files depending up conditions.

        • 1. Re: [js][cs4] How do I access a link modified date using a script
          John Hawkinson Level 5

          I believe you need to construct a new File() object and check its properties.

          1 person found this helpful
          • 2. Re: [js][cs4] How do I access a link modified date using a script
            twintern20 Level 1

            Thank you. I was able to find that answer since I posted the question in the "JavaScrip Tools Guide."

             

            I used:

            var file = File (docRef.links[i].filePath);

             

            I was then able to get the modified date and time by using: "file.modified"

             

            #target indesign
            main();
            function main() {
            if (app.documents.length == 0) {
            alert("Please have an 'Indesign' document before running this script.");
            return;
            }

             

            listLinks(docRef);
            };

            function listLinks(docRef, myStopCounter) {
                 var myCurrentTime = new Date ;
                 var myCalculatedMinutes = Date;

                 for (var i = docRef.links.length-1; i >= 0; i--) {
                       var file = File (docRef.links[i].filePath);
                  if (file.exists)
                        alert(docRef.links[i].name + " - " + DateDiff_inMinutes(myCurrentTime, file.modified), "Link name");
                  }// for/*/
            }

             

            function DateDiff_inMinutes(/*Date*/ date1, /*Date*/ date2) {     return (date1.getTime() - date2.getTime())/(1000*60); }