Created
August 28, 2020 11:43
-
-
Save indiscripts/7f6669c291451cc833041afb38fd4a0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(t,a,w,k,i,ff) | |
//---------------------------------- | |
// InDesign script. | |
// Show Grep/Text found items into a file. | |
{ | |
a = (t||0)&&('string'==typeof(app[(k='findGrep')+'Preferences'].findWhat)||'string'==typeof(app[(k='findText')+'Preferences'].findWhat)); | |
if(!a ) return; | |
w = new Window('palette',k); | |
w.margins = 25; | |
(w.add('staticText',void 0,"Running " + k + "...")).preferredSize=[250,22]; | |
w.show(); | |
w.update(); | |
if( !(a=t[k]()) || !(i=a.length) ){ w.hide(); alert("No result"); return; } | |
w.children[0].text = "Processing "+i+" found items..."; | |
for( ; i-- ; a[i]=a[i].contents ); | |
ff = File(File(Folder.temp) + '/' + k + '.txt'); | |
ff.open('w') && (ff.encoding='UTF8',ff.write(a.join('W'==ff.lineFeed[0]?'\r\n':'\n')),ff.close(),ff.execute()); | |
})(app.properties.activeDocument); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The finalized (and enhanced) snippet is now available in my IdGoodies repo:
• See DocGrepTextFindAll.jsx