How to remove all non-numeric characters from filename

One of our readers asked how to remove non-numeric characters from file names using the Microsoft PowerToys PowerRename tool. You can accomplish the task using regex.

Those who don’t have Microsoft PowerToys installed, download it from Install PowerToys | Microsoft Learn.

Remove text (non-numbers) from the file name

Method 1

This method also removes spaces within the file name.

  • Multi-select the files, right-click, and click PowerRename.
  • Use the following regex:
    [A-Z a-z]
  • Enable “Use regular expressions.”
  • Enable “Match all occurrences.”
  • Apply to “Filename only.”

As stated earlier, this also removes all the space (not just the leading and trailing spaces) in the file name.

powerrename non-numbers from file names

If you don’t want to remove the spaces, use Method 2 below.


Method 2

This method doesn’t remove the whitespaces within the file names, but it does remove the trailing whitespace(s).



In this method, we rename the files in two passes. In the first pass, we remove the non-numeric characters, and in the second pass, we remove the trailing whitespace(s), if any, in the file name.

  1. Multi-select the files, right-click and click PowerRename.
  2. First, use this regex:
    [A-Za-z]
  3. Enable “Use regular expressions.”
  4. Enable “Match all occurrences.”
  5. Apply to “Filename only.”
    After renaming the files, they will look like the ones below—i.e., the file names have a trailing white space before the dot.
    powerrename non-numbers from file names
  6. Next, use the following regex to remove one or more trailing spaces, if any, in the file name:
    ( *)$
  7. Enable “Use regular expressions.”
  8. Enable “Match all occurrences.”
  9. Apply to “Filename only.”

Here’s what the final output looks like—i.e., the trailing white space has been removed.
powerrename non-numbers from file names

That’s it!


Also, see Bulk Rename Utility, which has more features than PowerToys PowerRename.
https://www.bulkrenameutility.co.uk/


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time.

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a ten-time recipient of the Microsoft MVP award in Windows Desktop Experience (Windows Shell), from 2003 to 2012. Ramesh founded Winhelponline.com in 2005.

Leave a Comment