im trying to do a “get-childitem” search of directories that are all named with numbers.
a 5 digit minimum consisting of digits from 0 to 9. directory example names like the following “13476” or “334787”
tried the below… among many other attempts, and cant seem to get the results I’d like.

get-childitem c:\users | where-object {$ -like '*0-9*' }

how can I accomplish this?

ok… I got this to return correctly… is this the best way to accomplish it?
basically… I want it to return directory names that contain any integer of any length.

get-childitem c:\users | where-object {$ -match '[0-9]' }

Try something like this

Get-ChildItem -Path c:\ | Where-Object {$_.BaseName -match '(^\d[0-9])'}

I did test and it only gave me the folders that start with numbers.

awesome… thanks for the suggestion.

use \d+ or \d{min.max} syntax if you want to get 1+ or min to max numbers length. btw, \d its the same as [0-9]

“^\d+$” - give names that contains numbers only
“^\d{3,6}$” - give names that contains numbers only but only from 3 to 6 characters long
“^\d{5,}$” gives what you want - all digits, five or more

You can actually filter with Get-ChildItem:

Get-ChildItem -Path "C:\test\[0-9]*"

It’s referenced in this Powershell Tip:

thanks for the extra tips rob and max. its appreciated.
now that ive got this aspect of the script working… im running into the 256 character limit on directory length. always something.
thanks again guys for all the help