3
1
I want to search a folder on my computer for any file names matching "???x???.jpg"
.
Where the question marks can be 0-9, but I don't want it to match something like homxtop.jpg
.
Is this possible?
3
1
I want to search a folder on my computer for any file names matching "???x???.jpg"
.
Where the question marks can be 0-9, but I don't want it to match something like homxtop.jpg
.
Is this possible?
4
Yes with powershell
PS> dir | ?{$_.name -match "^[0-9]{3}x[0-9]{3}.jpg$"}
1
chingNotCHing already supplied a solution based on PowerShell but this one could be slightly faster depending on how many folders you're looking at and it could help if you're looking into a directory structure.
Get-ChildItem -Recurse -Filter "*.jpg" | Where name -match "^[0-9]{3}x[0-9]{3}.jpg$"
What this would do is look recursively for all *.jpg
starting from your current directory (which would already be a smaller set than a recursive dir
) and only filter those files for the actual pattern. To just look at the current directory you would drop the -Recurse
but in that case the simple dir
method should be more intuitive.
If you do just up vote it. :D – Seth – 2017-01-03T10:56:01.090
It's missing a parenthesis and could be rewritten as a simple
where name -match "^[0-9]{3}x[0-9]{3}.jpg$"
as it is a single condition. – Seth – 2016-12-30T10:55:57.313