Help needed for Find and Replace
hi,
i trying find , replace words .txt file indesign contents. if have repeated words in .txt file indesign did 3 times. below image illustrates better. sorry improving english convey requirement better.
script tried:
myfndchange(); function myfndchange(){ var myfolder = file.opendialog("select txt file proceed",issupportedtxt,true); if(myfolder!=null){filepath=decodeuri(myfolder);} if(myfolder==null){return;} var datafile = new file(filepath); datafile.open('r') ; while (!datafile.eof){ strlinein = datafile.readln(); colorarray = strlinein.split("\t"); var mycolumn1=colorarray[0]; var mycolumn2=colorarray[1]; var flag=0; x=mycolumn1.split(" "); app.findtextpreferences = app.changetextpreferences = null; app.findchangetextoptions.includelockedlayersforfind = true; app.findchangetextoptions.includelockedstoriesforfind = true; app.findchangetextoptions.includehiddenlayers = false; app.findchangetextoptions.includemasterpages = true; app.findchangetextoptions.includefootnotes = true; app.findchangetextoptions.casesensitive = false; app.findchangetextoptions.wholeword = true; mydoc=app.documents[0]; app.findtextpreferences = null; app.changetextpreferences = null; app.findtextpreferences.findwhat=mycolumn1; var myfound=mydoc.findtext(); for(i=0;i<myfound.length;i++){ if(myfound[i].words.length===x.length){ app.changetextpreferences.changeto = mycolumn1+"/"+mycolumn2; myfound[i].changetext() } } } } function issupportedtxt(file) { try { if (file instanceof folder) return true; else return file.name.match(/\.txt$/i) != null; } catch (e) { alert("error in issupported method: " + e); } }
thanks,
k
hello experts,
any quick suggestions appreciated. hope sort out issue.
regards,
karthi
More discussions in InDesign Scripting
adobe
Comments
Post a Comment