2 Replies Latest reply on Dec 7, 2018 8:00 AM by SergioMatos

    Export Alt-Texts + Import Alt-Texts

    SergioMatos Level 1

      Hello Script Masters, there is this Scripts that allows you to export your Custom Alt Text to a Text File, not sure if its possible to import it back after, incase you needed to make changes to any Alt text.

       

      Orignal

      Extract Alt-Texts

       

      AltText-Export.jsx

       

      //DESCRIPTION: This script will export all all text into single txt document on your desktop.

       

      #target indesign

       

      var images = app.activeDocument.allGraphics; // .itemLink.name

       

      var altTextFilePath = "~/Desktop/AltText.txt";

      var file = new File(altTextFilePath);

       

      file.open('w');

       

      for(var i=0; i < images.length; i++){

          file.write(  images[i].itemLink.name + "\n" + images[i].parent.objectExportOptions.customAltText + "\n\n" );

      }

       

      file.close();

       

      alert('You can find "AltText.txt" file on your desktop', "Done");

        • 1. Re: Export Alt-Texts + Import Alt-Texts
          Manan Joshi Adobe Community Professional

          Try the following, it will read the same file from Desktop that is produced from your code given above, and add custom alt text to images by finding them with name in the current open document.

          #target indesign
          var images = app.activeDocument.allGraphics;
          var altTextFilePath = "~/Desktop/AltText.txt";
          var file = new File(altTextFilePath);
          file.open('r')
          
          var altList = {}
          var imgName = file.readln()
          while(!file.eof)
          {
               altList[imgName] = file.readln()
               file.readln()
               imgName = file.readln()
          }
          for(var i=0; i < images.length; i++)
          {
               if(altList[images[i].itemLink.name] != undefined)
                    images[i].parent.objectExportOptions.customAltText = altList[images[i].itemLink.name]
          }
          file.close();
          

           

          -Manan

          • 2. Re: Export Alt-Texts + Import Alt-Texts
            SergioMatos Level 1

               you are God!.

             

            Thank you.