Finding files that end with Digits, after a Specific Character...

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
crimzind
Posts: 15
Joined: Sat Oct 14, 2023 4:48 am

Finding files that end with Digits, after a Specific Character...

Post by crimzind »

I'm trying to find files that end with one-to-four numbers, after a dash.
FileName-7.ext
FileName-50.ext
FileName-429.ext
FileName-8136.ext
...and then I want to replace(remove) the dash and the numbers.
FileName.ext
FileName.ext
FileName.ext
FileName.ext

I've tried searching for the answer/example here, and I've poked at the RegEx, but I suck with it.
I used HandBrake a few years ago to batch convert videos, and it appended incrementing numbers onto everything it output (I've since figured out how to stop that), and I sorted all those videos into a lot of different folders, and I'm just trying to clean the names up.
Last edited by crimzind on Sun Jan 28, 2024 11:27 pm, edited 1 time in total.
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Finding files that end with Digits, after a Specific Character...

Post by NotNull »

This should list the files ending in -<number>.<extension> :

Code: Select all

"C:\your starting folder\"   regex:"^.*-\d{1,4}\.[^.]+$"

Everything has a feature to rename and even move these files in one go. To rename these files:
  • Use the search above to find all matching files
  • Select all files (CTRL + A)
  • Menu => Edit => Advanced => Advanced Rename
  • In the Rename dialog, enable Regular Expressions
  • Old format = ^(.*)-\d+\.([^.]+)$
  • New format = \1.\2
  • In the New Filenames list, check if the filenames are formatted as expected
  • If all OK. press the OK button
  • Done!
Note: Be aware that this might lead to conflicting names. There can't be multiple filename.ext files in one folder.



If the files needs to moved to a different folder, more information is needed, like the structure of the paths currently used as well as the new destination of the files.



Regular Expression Syntax
crimzind
Posts: 15
Joined: Sat Oct 14, 2023 4:48 am

Re: Finding files that end with Digits, after a Specific Character...

Post by crimzind »

This is helping tremendously. Thank you, you're awesome.

The main thing I'd warn anyone using this for similar purposes about is to be aware of files that have Dates at the end in ##-##-##, ##-##-####, or ####-##-## styles. :P
Post Reply