How to search for non-ASCII characters in filenames?

Is there a quick way to search for non-ASCII characters in filenames?


I have thousands of files on an external hard drive and I'd like to find any non-ASCII troublemakers on there and rename the files without having to look at each filename one by one. Talk about eye strain.


I'm on a MacBook Air running Mojave.


Thanks in advance for suggestions!

MacBook Air

Posted on Nov 12, 2020 2:19 PM

Reply

Similar questions

6 replies

Nov 13, 2020 8:19 PM in response to arotolante

Before you make any attempts to change anything be sure to have a good backup first since something will most likely go wrong.


I found a few posts which contain some useful information which use bash commands to find filenames with non-ASCII characters. These posts contain some very good and interesting information so read them thoroughly as they involve character encoding which can have unforeseen effects on some regex. From these posts I think the "find" option or the "detox" options are the best ones. Chances are the macOS commands will be too old so you may need to use Homebrew to install newer versions of the commands, but make sure you run the Homebrew versions and not the macOS version. Maybe something here will help you.


https://stackoverflow.com/questions/19146240/find-and-delete-files-with-non-ascii-names


https://serverfault.com/questions/348482/how-to-remove-invalid-characters-from-filenames


https://unix.stackexchange.com/questions/109747/identify-files-with-non-ascii-or-non-printable-characters-in-file-name


Here is a blog about file name character issues. The following two sections may be the most relevant for TLDR:

Character Encoding Issues:

https://dwheeler.com/essays/fixing-unix-linux-filenames.html#utf8


See section 9.2 dealing with "find":

https://dwheeler.com/essays/fixing-unix-linux-filenames.html#tricks


You are on your own implementing a solution since it would take me a while to digest this information since my regex skills are very poor. Detox may be the easiest and safest option.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to search for non-ASCII characters in filenames?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.