Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

File Name from Character through hard return. Almost there.

$
0
0

Hi all! I have a script that is naming my files by the characters in two text frames.

It works... to a point.

For some reason it is duplicating the name.

This is the final result. > test-2-wealth-file-stuff,2-wealth-file-+-stuff.jpg

when it should be this. > test-2-wealth-file-stuff.jpg

for some reason it is adding > ,2-wealth-file-+-stuff

 

any idea why? Thanks in advance.

 

main ();

function main() {

var curDoc = app.activeDocument;


// loop through all pages
for ( var i = 0; i < curDoc.pages.length; i++ ) {    // the current page    var curPage = curDoc.pages[i];    var pName = curPage.name;    // controls the loop    var controller = true;    // all paragraphs on the current page  var allPages = (curPage.textFrames.everyItem().paragraphs[0]); {
pageName=allPages.characters.itemByRange(0,allPages.contents.toString().indexOf("^p") -1);  var paraName = "" + pageName.contents;
var paraString = "-" + paraName.replace( /\s+$/ , "" ).replace( /\s+/g , "-" ).toLowerCase().replace('+', '');


}



var folderPath = "~/-client/" ;
   {        var appendix = paraString;    }      var filePath = folderPath + "/" + curDoc.name.replace(/\.indd$/,"") + appendix + ".jpg";    var myFile = File( filePath );    with ( app.jpegExportPreferences) {        jpegQuality = JPEGOptionsQuality.MAXIMUM; // low medium high maximum        exportResolution = 72;        jpegExportRange = ExportRangeOrAllPages.exportRange;        pageString = pName;    }    curDoc.exportFile( ExportFormat.jpg, myFile, false );  } // end for > pages


} // end for > main

Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>