actually that code after i did editing to be a multiple find/replace function main(){ var doc=app.activeDocument; var myDialog= new Window("dialog","Font Find/Change"); var grp1=myDialog.add("group"); var panel1=grp1.add("panel",undefined,"Find Font:"); var panel2=grp1.add("panel",undefined,"Change Font:"); var findFonts1=doc.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var chFonts1=app.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var myFindDrop1=panel1.add("dropdownlist",undefined,findFonts1); var myChDrop1=panel2.add("dropdownlist",undefined,chFonts1); var grp2=myDialog.add("group"); var panel3=grp2.add("panel",undefined,"Find Font:"); var panel4=grp2.add("panel",undefined,"Change Font:"); var findFonts2=doc.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var chFonts2=app.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var myFindDrop2=panel3.add("dropdownlist",undefined,findFonts2); var myChDrop2=panel4.add("dropdownlist",undefined,chFonts2); var grp3=myDialog.add("group"); var panel5=grp3.add("panel",undefined,"Find Font:"); var panel6=grp3.add("panel",undefined,"Change Font:"); var findFonts3=doc.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var chFonts3=app.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var myFindDrop3=panel5.add("dropdownlist",undefined,findFonts3); var myChDrop3=panel6.add("dropdownlist",undefined,chFonts3); var grp4=myDialog.add("group"); var panel7=grp4.add("panel",undefined,"Find Font:"); var panel8=grp4.add("panel",undefined,"Change Font:"); var findFonts4=doc.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var chFonts4=app.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var myFindDrop4=panel7.add("dropdownlist",undefined,findFonts4); var myChDrop4=panel8.add("dropdownlist",undefined,chFonts4); var grp5=myDialog.add("group"); var panel9=grp5.add("panel",undefined,"Find Font:"); var panel10=grp5.add("panel",undefined,"Change Font:"); var findFonts5=doc.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var chFonts5=app.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var myFindDrop5=panel9.add("dropdownlist",undefined,findFonts5); var myChDrop5=panel10.add("dropdownlist",undefined,chFonts5); var grp6=myDialog.add("group"); var panel11=grp6.add("panel",undefined,"Find Font:"); var panel12=grp6.add("panel",undefined,"Change Font:"); var findFonts6=doc.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var chFonts6=app.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r"); var myFindDrop6=panel11.add("dropdownlist",undefined,findFonts6); var myChDrop6=panel12.add("dropdownlist",undefined,chFonts6); myDialog.add("button",undefined,"Ok",{name:"ok"}); myDialog.add("button",undefined,"Cancel",{name:"cancel"}); myFindDrop1.selection=myFindDrop1.items[0]; myChDrop1.selection=myChDrop1.items[0]; myFindDrop2.selection=myFindDrop2.items[0]; myChDrop2.selection=myChDrop2.items[0]; myFindDrop3.selection=myFindDrop3.items[0]; myChDrop3.selection=myChDrop3.items[0]; myFindDrop4.selection=myFindDrop4.items[0]; myChDrop4.selection=myChDrop4.items[0]; myFindDrop5.selection=myFindDrop5.items[0]; myChDrop5.selection=myChDrop5.items[0]; myFindDrop6.selection=myFindDrop6.items[0]; myChDrop6.selection=myChDrop6.items[0]; if (myDialog.show()) { var pstyles = doc.allParagraphStyles; var cstyles = doc.allCharacterStyles; var ffont = myFindDrop2.selection.text.replace(/:/g,"\t"); var tfont = myChDrop2.selection.text.replace(/:/g,"\t"); for (var a = 1; a < pstyles.length; a++) { if (pstyles.appliedFont.name==ffont) { pstyles.appliedFont = tfont; var pstyles = doc.allParagraphStyles; var cstyles = doc.allCharacterStyles; var ffont = myFindDrop1.selection.text.replace(/:/g,"\t"); var tfont = myChDrop1.selection.text.replace(/:/g,"\t"); for (var a = 1; a < pstyles.length; a++) { if (pstyles.appliedFont.name==ffont) { pstyles.appliedFont = tfont; var pstyles = doc.allParagraphStyles; var cstyles = doc.allCharacterStyles; var ffont = myFindDrop3.selection.text.replace(/:/g,"\t"); var tfont = myChDrop3.selection.text.replace(/:/g,"\t"); for (var a = 1; a < pstyles.length; a++) { if (pstyles.appliedFont.name==ffont) { pstyles.appliedFont = tfont; var pstyles = doc.allParagraphStyles; var cstyles = doc.allCharacterStyles; var ffont = myFindDrop4.selection.text.replace(/:/g,"\t"); var tfont = myChDrop4.selection.text.replace(/:/g,"\t"); for (var a = 1; a < pstyles.length; a++) { if (pstyles.appliedFont.name==ffont) { pstyles.appliedFont = tfont; var pstyles = doc.allParagraphStyles; var cstyles = doc.allCharacterStyles; var ffont = myFindDrop5.selection.text.replace(/:/g,"\t"); var tfont = myChDrop5.selection.text.replace(/:/g,"\t"); for (var a = 1; a < pstyles.length; a++) { if (pstyles.appliedFont.name==ffont) { pstyles.appliedFont = tfont; var pstyles = doc.allParagraphStyles; var cstyles = doc.allCharacterStyles; var ffont = myFindDrop6.selection.text.replace(/:/g,"\t"); var tfont = myChDrop6.selection.text.replace(/:/g,"\t"); for (var a = 1; a < pstyles.length; a++) { if (pstyles.appliedFont.name==ffont) { pstyles.appliedFont = tfont; } } } } } } } }; for (var i = 1; i < cstyles.length; i++) { if ((cstyles.appliedFont+'\t'+cstyles.fontStyle==ffont)||(cstyles.appliedFont.name==ffont)) { cstyles.appliedFont = tfont; } }; } } } } } }app.doScript("main()",undefined,undefined,UndoModes.fastEntireScript,'Global Change Font');
... View more