Corrupted file names?

If you, like me are from some country where we use characters outside your average ascii-spectrum, you might have some filenames with your local chars in them.

Now, in a perfect world, this might not be a problem, because all your computers, external hard drive and the NAS has the same encoding, so this works fine.

For me however, whenever I run my backup-script, I get error messages. Some filenames have been «corrupted» being like this «st°rste sand°y..jpg» or «vÕr.jpg». I did not try to figure out the encoding of the file-name, or why they got invalid characters.

What i did to fix this issue, was to run the following script, found on the interwebz.


find /path/to/files -type f -print0 | \
perl -n0e '$new = $_; if($new =~ s/[^[:ascii:]]/_/g) {
 print("Renaming $_ to $new\n"); rename($_, $new);

I am always careful not to run scripts, found on the internet without knowing that it is not harmful, and this also applies for you.

When I’m on the topic of the alphabet: This youtube-video elaborates how we see things from the cold north.

Hope this fixes things for you as well.

Leave a Reply

Your email address will not be published.