From time to time, in our customers' businesses, it is necessary to search a large number of files for particular keywords. This is done for archiving, auditing, or discovery purposes. A couple weeks ago, one of our clients requested us to run a search on the company email files. To do this our team used the "findstr" command; however, the search reached an error caused by an input/output path with more than 254 characters.
Example: findstr /M /s /i /c:"String I want to find" c:\path to thing\path\path\path\path\*.eml > C:\path\results2.txt
Issue: Trying to do a findstr on a bunch of files (in this case email files) and parse results to a text file causes “FINDSTR: Out of memory” and aborts search.
System: Windows Server 2008 R2 Standard
Error Code: “FINDSTR: Out of memory”
Solution:
Move to the long path before running the findstr cmd to make the path shorter.
Fixed example:
C:
Cd c:\path to thing\path\path\path\path\
findstr /M /s /i /c:"String I want to find" *.eml > C:\path\results2.txt
NOTE: this condition also occurs in Windows Power Shell, for example when trying to copy files like so:
Get-ChildItem c:\path to thing\path\path\path\path\ -Filter *.eml -Recurse | Select-String " String I want to find " | Copy-Item -Destination C:\path\
Thus, you will need to make your Power Shell scripts use relative paths also. However, Power Shell is nice about the error and gives a clear description if the issue for each file it hits that has an overly long path. It also seems to recover better from the condition and keep running.
After applying these resolution steps, the team completed the search and delivered the results to our client. We provide complete server, workstation, and computer network support to businesses and organizations with fifty or fewer employees. We often support our customers with computer troubleshooting and technical help.
Kent