April 12th, 2015

PowerTip: Use PowerShell to Find Files in Wrong Folder

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to easily find files that are in the wrong folder.

Hey, Scripting Guy! Question I have a folder for documents and another folder for images. But at times, I discover images in the
           documents folder. How can I use Windows PowerShell to easily detect this situation?

Hey, Scripting Guy! Answer Use the Test-Path cmdlet, and specify the file extension to exclude, for example:

PS C:\> test-path c:\fso -Exclude *.bmp

True

PS C:\> dir c:\fso -Include *.bmp

PS C:\> 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.