Skip to content

Instantly share code, notes, and snippets.

@indiscripts
Created August 28, 2020 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indiscripts/7f6669c291451cc833041afb38fd4a0c to your computer and use it in GitHub Desktop.
Save indiscripts/7f6669c291451cc833041afb38fd4a0c to your computer and use it in GitHub Desktop.
(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);
@indiscripts
Copy link
Author

The finalized (and enhanced) snippet is now available in my IdGoodies repo:

• See DocGrepTextFindAll.jsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment