Scanning HTML and PHP files for text

How to search for text strings in files using the WinOne® Command Language Interpreter (CLI).

There are a lot of questions asked in WordPress forums about how to find which file to edit to change the appearance or behavour of WordPress themes or plugins. To identify the file or files your looking for you need to scan all the files for the text your interested in. I use WinOne for this purpose.

Looking at the website it’s not really clear how useful the WinOne software is and how to use it. This therefore is an example of how to use one feature of WinOne – the “FIND” command to scan folders of files for text strings.

As a preparatory action you need to download a copy the folder/directory containing the theme or plugin files from your website to your PC. For the purposes of this demonstration I’ve downloaded a copy of the NextGEN gallery plugin to my F: drive.

(1) Download and install WinOne onto your PC. It’s currently free to use for up to 30 days and costs less than $5 to purchase a licence if you wish to continue using it after that.

(2) Start WinOne by clicking on the WinOne Command Shell icon on your desktop.

(3) Select the disk drive your files are on by clicking on the appropriate drive icon at the bottom of the WinOne window.

Disk Drive Selection

(4) Navigate to the directory your files are in using the Change Directory (cd) command to select the drive you downloaded the theme or plugin code to.

Change Directory

(5) Use the FIND command to scan the files for the text your searching for.

Command FIND
Search for a text string in the specified files.

FIND [drive:][path]filename “textstring” [/S] [/M]

[drive:][path]filename Specifies the text file(s) to search.
textstring Specifies the text string to find.
/M Match case.
/S Process sub-directories.

Command FIND uses the fast Boyer-Moore Algorithm and will only search text files. Non-text file are simply skipped.
Command FIND is not compatible with the DOS command FIND.
Unlike the DOS command FIND, Wildcards are allowed for parameter filename.

Example 1 – Direct the output from the FIND command to the screen.
To find all files containing the string “alttext” enter find * /S “alttext”

Find Screen Output

Example 2 – Direct the output from the FIND command to a file.
To find all files containing the string “alttext” and redirect the output to a file enter
find * /S “alttext” > /temp/alttext.txt then open the file /temp/alttext.txt in your favourite file editor (notepad, notepad++ etc) to view the search results.

Find File Output

Having found the file or files your interested in you can open them to review the content or make changes as necessary to suit your requirements.

WinOne operates with a mix of DOS and UNIX like commands and syntax so in the above example you could for instance, append the output to a file by using >> rather than > which overwrites.

I have no financial interest in WinOne and the infomation provided here is supplied because I find the software very useful and it may be of interest to others.