7 Replies Latest reply on Jan 16, 2016 4:02 AM by pixxxel schubser

    Add alt text to a CSV file

    mramjbarnes

      I have modified a script (LinkExport-Pro_1a.jsx) from Martin Fischer (many thanks) but want to add the "Custom Alt text" form the images to this CSV file, can anyone help?

       

       

      // LinkExport-Pro_1a.jsx 
      //DESCRIPTION: Exports some information about placed images in the active Document into a textfile in the same folder as the document.  
      // The values are tab-separated, so that the content of the file can be copied to Excel via Clipboard. 
      // The exported textfile has the ending ".txt". 
      // Script by Martin Fischer (www.hilfdirselbst.ch)
      // 
      var myDoc = app.documents[0]; 
      if (myDoc.saved == false) 
      { 
        alert("Error.\rYou must first save your document."); 
        exit(); 
      } 
      var myDocName = myDoc.name.split(".indd")[0]; 
      var myTXT_File = myDocName + '.csv'; 
      var myPath = myDoc.filePath + "/"; 
      var myCreator = "R*ch";  
      var myType = "TEXT";  
      var theFiles = myDoc.links; 
      var myData = "link\,path\,page\r";  
      
      var f = new File( myPath + myTXT_File );  
      f.open( 'w', myType, myCreator );  
      f.writeln( myData );  
      
      for (myCounter = 0; myCounter<theFiles.length;myCounter ++ ) {  
      
        var myImagePath = theFiles[myCounter].filePath; 
                  csvSep=",";
        // WARNING if vertical scale is different to horizontal scale 
      
        var myClass = theFiles[myCounter].parent.parent.parent.constructor.name; 
        // image placed on page 
        if (myClass == "Page")  
        {  
        myPage = theFiles[myCounter].parent.parent.parentPage.name; 
        }  
        // image embedded 
        else if (myClass == "Character") 
        { 
        try  
        {  
        myPage = theFiles[myCounter].parent.parent.parent.parentTextFrames[0].parentPage.name; 
        } 
        catch(e) 
        { 
        myPage = "hidden in the overflow"; 
        } 
        }  
        else { 
        try  
        {  
        // image placed outside the pages 
        myPage = "Spread of " + theFiles[myCounter].parent.parent.parent.pages[0].parentPage.name; 
        }  
        catch(e)  
        {  
        // don't know the page where the image is placed 
        alert ("Class: " + myClass + "\r" + theFiles[myCounter].name); 
        }  
        }  
      
      
      
      
      
      
         // myData = theFiles[myCounter].name+csvSep+myImagePath+csvSep+myPage+csvSep+myWidth+csvSep+myHeight+csvSep+myScaleVert+csvSep+myScaleHori+csvSep+myPPI + "\r"; 
      
          myData = theFiles[myCounter].name+csvSep+myImagePath+csvSep+myPage + "\r"; 
        f.writeln(myData);  
      }  
      f.close();