Monday, October 28, 2019

linux - Can't copy files with accents to Mac OS


I have server which is sharing files through SMB. Server is using Ext4 to store files.


Today I tried to copy the following file from server to Mac OS:


1-10 Bizet_ Carmen - Habañera.wav

First time it copied but I couldn't see the file itself. Second time I copied to same place and got error code -8058. After some digging I've found that for some reason this particular file is copied as link in the following way:


file-//localhost/Volumes/torrents-tmp/downloads/1-10%20Bizet_%20Carmen%20-%20Haban%CC%83era.wav.webloc

From within 100 files around 10% files are giving same problem. I'm not even able to rename it from Mac OS. If I rename to n from server, then I can copy it.


Another example of such file is:


10 Celebración.wav

So it appears accents are confusing Mac OS, but I thought they are part of Unicode.


As solution to be able to copy it over, how can I mass rename all invalid files automatically?


Answer



Run this on the server to rename the files. It will replace all non-ascii characters with their ascii equivalent:


find . -type f  |
perl -nCAS -MText::Unidecode -e 'chomp; rename "$_", unidecode("$_");'

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...