0

What search pattern can I use in Windows File Explorer search field to find all files ending in a negative number? I'm looking for a search pattern that only finds 1 or 2 digit negative numbers at the end of the file name.

I'm currently using the following search pattern: *-?.* OR *-??.*

It works well, but it also list files having a non-numeric character. (Foo-A.mp4), (Wiget-AA.mp4)

I have a download folder where I download many files, and when I download duplicate files, a negative number is attached. I use the search pattern to find the duplicates and delete them, and I want to avoid deleting the wrong files by having a better search input.

Example file list:

Batman-1.mp4
Batman-1995.mp4
Batman-1A.mp4
Ben10-1.mp4
Ben10.mp4
TeensTitans-1.mp4
TeensTitans-11.mp4
TeensTitans-2.mp4
TeensTitans.mp4

Using *-?.* OR *-??.*, the results also includes (Batman-1A.mp4), which I'm trying to avoid.

enter image description here

According to both of the below links, # (pound/hashtag) can be used as a wildcard for numbers, but I can't get it to work on my Windows 11 computer.

https://windows101tricks.com/windows-10-search-tricks/ https://mashtips.com/windows10-best-search-tricks/


I'm only interested in a solution using Windows File Explorer.

I appreciate any input. Thank you

1
  • 2
    It's not actually a negative number, it's a positive number separated by a 'hyphen minus' sign. That doesn't make your task any easier, because that just the same sign used when hyphenating or making sure you don't leave blank spaces. It's basically the 'least specific' dash sign possible.
    – Tetsujin
    Oct 3, 2022 at 18:43

2 Answers 2

1

Windows Search cannot do that - its wildcard expressions are just too limited.

You could instead use the Command Prompt (CMD) with the findstr command that supports some regex, this way:

dir /b | findstr /RC:"-[0-9]*.mp4$"

Or you may use a third-party utility that supports full regex, such as the excellent Everything of voidtools.

5
  • Sorry, but I think windows can do it. According to the following link, # (pound/hashtag) can be used as a wildcard for numbers, but I can't get it to work on my Windows 11 computer. ------------------------------------------------------------------------- windows101tricks.com/windows-10-search-tricks Oct 5, 2022 at 17:08
  • If I can't get File Explorer to work, I'll see if I can use your syntax in a DOS batch file to simulate what I want. Thanks Oct 5, 2022 at 17:08
  • harrymc, I just tried your command, and it doesn't produced the correct results, because it also includes "Batman-1995.mp4" in the results. I specified in the question that I only wanted results having 1 or 2 digit numbers after the minus (dash) character. Oct 5, 2022 at 17:23
  • Also, I can't include the file type in the script (cmd) because there are many different file types in the folder, and multiple folders. I tried to keep the question simple, so I didn't post the example listed with a variety of file types. When a wildcard is used for the file type, there doesn't seem to be a way to stop numbers having more than 2 digits from being included in the results. -----------------------------------------------------------------/RC:"-[0-9].*$" Oct 5, 2022 at 17:35
  • Sorry, for so many multiple replies. I just relies the R in your command line is for REGEX (regular expressions). I'm pretty familiar with REGEX, and I'm sure I can modify your example so that it produces the correct output. Oct 5, 2022 at 17:45
0

If you prefer PowerShell to cmd.exe, use:

gci | ? BaseName -match '-\d+$'
1
  • I don't like using PowerShell for small scripts because it's overly complicated when trying to move the scripts to another computer, unless the script is signed, or you bypass the signage check. Oct 5, 2022 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .