The original grep was a pure command line tool. Modern Windows applications often only provide a point-and-click interface. PowerGREP provides the best of both worlds. All of its features can be used through both its rich graphical user interface (GUI) as well as via the command line.
Most of the time you’ll work with PowerGREP’s GUI. It’s by far the easiest way. Any feature is never more than a few clicks away. That’s why this website and PowerGREP’s user’s guide focus on using PowerGREP through the point-and-click interface. Screen shots of PowerGREP’s GUI also look much better than screen shots of the Windows command prompt.
But if you’re a command line junkie, you can access PowerGREP’s most frequently used features with direct command line parameters. For example, you could initiate a search with this command line: PowerGREP5.exe /search /regex /searchtext “foo|bar” /folder “C:\My Documents” /masks “*.txt” “*.bak” “” “” 0 /preview
To automate this from a batch file or a script, you could replace /preview with /execute /save “C:\output\results.html” /quit to save the search results into an HTML file for later inspection. You could use /silent instead of /execute /quit to do the same silently, which means PowerGREP will run the search without showing anything on your monitor.
Silent execution is great for scheduled searches or file maintenance tasks. If you have an automated process that regularly delivers new files, you can schedule PowerGREP to process those files at regular intervals. While PowerGREP doesn’t have any built-in scheduling features, you can easily run it through any task scheduling software, including the Windows Task Scheduler that is included with Windows 2000 and later.
The easiest way to do this is to first prepare and test your action with PowerGREP’s graphical interface. When ready, select Action|Save in the menu to save all the settings from the Action and File Selector panels into a .pga file. Then configure your task scheduler to run PowerGREP passing the full path to the .pga file along with the /silent switch on the command line. Make sure to put double quotes around the path to the .pga file if it contains spaces. The screen shot in the margin shows what this looks like with the Windows 8.1 task scheduler. Don’t worry if the “add arguments” box seems tiny. It is tiny, but it still accepts about 5,000 characters.
Because all file selection and action options can be saved into .pga files, anything you can do in PowerGREP’s interface, you can do on its command line. Better still, the .pga files are XML files with a published schema. So anything you can do in PowerGREP’s interface, you can do from a program or script that you write, simply by having it write or modify a .pga file that you then pass on the command line to PowerGREP.
If you need to schedule more than one action to be executed in sequence, add all those actions to the Sequence panel in PowerGREP. Then select Sequence|Save in the menu to save everything into a .pgsa file. Pass this on the command line to have PowerGREP execute the entire sequence.