0 Replies Latest reply on Dec 10, 2008 2:27 PM by (nelgom)

    LabelGraphics Script

      Hi Everyone, I don't know much about scripting so I'm hoping someone can help me. I'm trying to modify the LabelGraphics script to capture the "Date Created" field. I have tons of images that I need to organize based on their date of creation but I need to see the date with the image in the layout (long story). Anyway, I have tried to change XMP Author to Date Created but nothing. Below is the script as it came from Adobe. Any help will be greatly appreciated.

      //LabelGraphics.jsx
      //An InDesign CS3 JavaScript
      /*
      @@@BUILDINFO@@@ "LabelGraphics.jsx" 1.0.0 14-September-2006
      */
      //Adds labels to the graphics in the active document.
      main();
      function main(){
      if(app.documents.length != 0){
      if(app.documents.item(0).allGraphics.length != 0){
      myDisplayDialog();
      }
      else{
      alert("Document contains no graphics.");
      }
      }
      else{
      alert("Please open a document and try again.");
      }
      }
      function myDisplayDialog(){
      var myLabelWidth = 100;
      var myStyleNames = myGetParagraphStyleNames();
      var myDialog = app.dialogs.add({name:"LabelGraphics"});
      with(myDialog.dialogColumns.add()){
      //Label type
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Type", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelTypeDropdown = dropdowns.add({stringList:["File name", "File path", "XMP description", "XMP author"], selectedIndex:0});
      }
      }
      //Text frame height
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Height", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelHeightField = measurementEditboxes.add({editValue:24});
      }
      }
      //Text frame offset
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Offset", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelOffsetField = measurementEditboxes.add({editValue:0});
      }
      }
      //Style to apply
      with(dialogRows.add()){
      with(dialogColumns.add()){
      staticTexts.add({staticLabel:"Label Style", minWidth:myLabelWidth});
      }
      with(dialogColumns.add()){
      var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:0});
      }
      }
      }
      var myResult = myDialog.show();
      if(myResult == true){
      var myLabelType = myLabelTypeDropdown.selectedIndex;
      var myLabelHeight = myLabelHeightField.editValue;
      var myLabelOffset = myLabelOffsetField.editValue;
      var myLabelStyle = myStyleNames[myLabelStyleDropdown.selectedIndex];
      myDialog.destroy();
      var myOldXUnits = app.documents.item(0).viewPreferences.horizontalMeasurementUnits;
      var myOldYUnits = app.documents.item(0).viewPreferences.verticalMeasurementUnits;
      app.documents.item(0).viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
      app.documents.item(0).viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
      myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyle);
      app.documents.item(0).viewPreferences.horizontalMeasurementUnits = myOldXUnits;
      app.documents.item(0).viewPreferences.verticalMeasurementUnits = myOldYUnits;
      }
      else{
      myDialog.destroy();
      }
      }
      function myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName){
      var myDocument = app.documents.item(0);
      var myGraphics = myDocument.allGraphics;
      myLabelStyle = myDocument.paragraphStyles.item(myLabelStyleName);
      for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){
      myAddLabel(myDocument, myGraphics[myCounter], myLabelType, myLabelHeight, myLabelOffset, myLabelStyle);
      }
      }
      function myAddLabel(myDocument, myGraphic, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle){
      var myLabel;
      var myLink = myGraphic.itemLink;
      //Create the label layer if it does not already exist.
      var myLabelLayer = myDocument.layers.item("labels");
      try{
      myLabelLayer.name;
      }
      catch (myError){
      myL