Regarding Windows

The “findstr” Command and Regex in DOS

Recorded on December 15th, 2016

I learned another cool DOS command line trick today. You can use the findstr command to match regex patterns in the output coming from the dir command. Here’s an example from Stack Overflow:

What does the DOS command “findstr” do here? - Stack Overflow

You use the command like this, putting whatever your match string is in quotes:

dir | findstr "test[0-9][0-9][0-9]test"

pushd and popd for Setting the Current Directory to a UNC Path

Recorded on November 17th, 2016

I learned a cool trick today. I needed to switch the current directory in a Windows command prompt window to a server folder at a UNC (Universal Naming Convention) path in the form of \\Server\Volume\File. But the Windows “cmd” command line window only accepts cd commands with a drive letter when you’re giving an absolute path. If you try to put a UNC path in there, you’ll get an error message.

The workaround is to use
pushd and popd when you need to set the current directory to a UNC path. It maps a temporary virtual drive letter to that path and sets the current directory to it. Then you go about your business at the command line. When you’re done, you type popd, which will delete the temporary drive mapping and get you back to where you were.