Sunday, January 18, 2009

find all files with specified criteria

[] to find all files in the Windows directory with the suffix .log and exactly five characters in the base name

PS> get-childitem -path c:\lindows\?????.log


Directory: Microsoft.PowerShell.Core\FileSystem::C:\lindows


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2008-Nov-30 12:41 PM 5868 ocgen.log
-a--- 2008-Dec-10 8:56 AM 194 setup.log

[] to find all files that begin with the letter 'c' in the Windows directory

PS> get-childitem -path c:\windows\system32\c*

[] to find all files whose names begin with 'u' or 'z'

PS> get-childitem -path c:\windows\system32\[uz]*

[] to find 32-bit Windows compatibility DLLs excluding Windows 95 and 16-bit type in the System32 folder

PS> get-childitem -path c:\windows\system32\w*32*.dll -exclude *[9516]*

[] to restrict the items to those that are in the Windows folder with names end with '*.dll', excluding those names from 'a to y'

PS> get-childitem -path c:\lindows -Include *.dll -recurse -exclude [a-y]*.dll

No comments:

Post a Comment