' ); return $kruimelpad; } ?>

Getting to know my computer

Problem to solve: fast find occurences of a string in thousands of files on a Windows computer

The first computer I ever worked with was the Mac SE, small, heavy, loud, with a nice graphical user interface. When I decided to follow a computer class, the first screen I saw was black with a nice c:\>. I thought the computer was broken. Windows 3.1 was yet to come. I never paid much attention to all the possibilities Windows offers nowadays until a few days ago.

I had thousands of files and wanted to know if a certain string was missing. My idea was to upload all the files to a Unix host and use a Unix command. But there came Powershell to the rescue. At first I thought that Powershell was just another fancy name for what used to be MS-DOS. That is not the case. Long story short, Powershell is far more powerful and it actually had the command I needed. You can read a small introduction to Powershell on programminghistorian.org.

Mac SE - image from Wikipedia
Mac SE – image from Wikipedia, yes those are two floppydrives 🙂

Finding (or not) a string in thousands of files

While importing thousands of json files from different subdirectories into Power BI, I got an error message indicating that a certain part in the importfiles was missing and the import stopped. To make sure I understood the error message correctly, I wanted to know if a certain string “line” was missing from these files. Powershell has a nice command findstr to do exactly that, “find files with a (missing) string”. “findstr /s /v line *” searches all the files in subdirectories, relative to the subdirectory where you execute the command, for a missing string ‘line’ and has many more options. I got a lot of files with the missing string and could conclude that order records without order lines were not an incident but a serious problem to solve.

Output of findstr command
Output of findstr command