How do I remove or replace every special character in every filename in a directory?

I have a folder of 220+ GB of backups from an old PC. There are I don't know how many files all with some special characters. I'm trying to compress the folder, but it doesn't work with these special characters.

I do not want to go through every single file, check every single name, and remove every single special character in a folder that's over 200 GB large.

Is there a method to remove every special character, or replace them with something else, without going through every single file?

Answer
Answer

You can definitely use PowerToys' PowerRename utility to do this, although it will undoubtedly take a long, long time to trawl through 220GB of files.

Without knowing which characters your compression software is choking on, you'd have to play very safe. Here is an example; the two files in the folder I selected have names containing å, ð and ó, which may be out of gamut although Windows doesn´t mind them. Note that I selected Use Regular Expressions which allow me to specify a pattern rather than text. The pattern I chose is 

[^A-Za-z0-9-_]

This just means 'find any character in the filename that isn't (that's what the ^ does) one of the characters A-Z, a-z, 0-9, - (dash) or _ (underline)'.  The dash has to be preceded by a \ ('escaped') because otherwise the program would try to interpret it in the same way as the one between A and Z. Escaping means that the program will treat it literally. 

In the Replace box, I have two dashes, so you should be able to tell at a glance that a character has been removed after renaming.

 

Match All Occurrences must be selected when using regular expressions. I chose also only to check the filename part ('Item Name Only') assuming that the files have meaningful, normally-used extensions like doc or jpg

You can see the results before committing to the changes.

  

I suggest you experiment a bit in a sample folder before using it on your precious backups. 

Noel Burgess MVP (Ret'd)

26 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated February 24, 2025 Views 39,445 Applies to: