I'm working on a script that goes through folders with multiple .pdf-files in it. Only when the name of the file fits one of two masks, Powershell should continue executing certain steps. Else it should continue to search for the next file fitting the mask.
I've used:
Get-ChildItem $PATH -Filter "*TEXT-TXT-*" -Recurse -Force |Foreach-Object {
write-host $_.Name
But this filters only hardcoded. How to use a mask and preferable use two mask as filter? The masks should be:
Where # are any numbers and X are any non-number characters.
Hope this is possible.
for this you can use regular expressions, add several conditions to them through "or" for example as follows
Get-ChildItem $PATH -Filter "*TEXT-TXT-*" -Recurse -Force|Where-Object {($_.name -match '\d{2}-\d{2}-\d{4} \w{4}-\w{3}-\w{3}-\w{4}-\w{2}.PDF') -or($_.name -match '\d{2}-\d{2}-\d{4} \w{4}-\w{3}-\w{4}-\w{2}.PDF')}
in this expression it is enough to substitute the name of the file transmitted by the piping