here is a slightly different way to get the file list. [grin] it tests against the .Directory
property of the files.
_[edit - the original version matched against the entire dir name AND failed to get dir names with ONLY the date pattern.]_
$SourceDir = $env:temp
$Filter = '*.log'
# this pattern will give embedded date patterns
#$DirPattern = '\d{4}-\d{2}-\d{2}'
# this pattern gives ONLY a date pattern
$DirPattern = '^\d{4}-\d{2}-\d{2}$'
$GCI_Params = @{
LiteralPath = $SourceDir
Filter = $Filter
File = $True
Recurse = $True
}
$FileList = Get-ChildItem @GCI_Params |
# this matches against the entire directory
#Where-Object {$_.Directory -match $DirPattern}
# this one correctly filters against only the parent dir
Where-Object {(Split-Path -Path $_.DirectoryName -Leaf) -match $DirPattern}
$FileList.Count
on my system, at this time, it returns ~~67~~ 54
as the count of matching files.