Share via

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

Anonymous
2021-03-09T15:54:40+00:00

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?

Windows for home | Windows 10 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Anonymous
    2021-03-14T08:54:50+00:00

    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.

    20+ people found this answer helpful.
    0 comments No comments

15 additional answers

Sort by: Most helpful
  1. Paulo GM 63,705 Reputation points Independent Advisor
    2021-03-09T16:45:04+00:00

    Hi kevinTOC, I am Paulo, an Independent Advisor, and I'm willing to help.

    You can use a tool from PowerToys called PowerRename. It can do bulk renaming of folders including their contents or files. PowerToys is a preview tool from Microsoft that you can download on Microsoft's GitHub page.

    https://github.com/microsoft/PowerToys/releases...

    You can check this screenshot of the tool that I tested on folders with subfolders and contents and see if it could work for you

    Let me know if this helps.

    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2021-03-09T19:20:38+00:00

    Are the files actually readable? Strange characters in file names are often caused by file system corruption which means that the files are no longer readable. Renaming them would not achieve anything.

    Yes, the files are perfectly readable. The files don't seem to affect the ability of the programs that use them to read them.

    The characters aren't like "glitched" characters (I dunno how to describe it), they're just regular characters that have meaning. (Like Japanese characters, TM symbols, or Copyright symbols.)

    Renaming them did work, since I never got any error on the files when I tried to compress them again.

    I'm trying to compress them into a file that's on a Seagate 4TB expansion drive, I dunno if that does anything, I'm moving files only within the drive

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2021-03-09T16:07:49+00:00

    What special characters are you thinking of?

    1 person found this answer helpful.
    0 comments No comments
  4. Anonymous
    2021-03-09T16:44:40+00:00

    I'm trying to compress the folder, but it doesn't work with these special characters.

    I've never heard of compression failing due to special characters. Is that the error message you are receiving from your compression application?

    To a compression algorithm there are only two characters: 0 and 1.

    0 comments No comments