3

I have a directory within my iTunes folder structure that has an accent character in it which I am trying to delete.

If I do an ls on the directory I get this:

ls -al ls: Radiů Disney_ Jams Vol. 2: No such file or directory total 0 drwxr-xr-x 3 scott staff 102 Jul 29 13:16 . drwxrwxr-x@ 21 scott staff 782 Jul 29 13:24 ..

I've tried rm -rf * but after that I attempt an ls -l I still get: ls: Radiů Disney_ Jams Vol. 2: No such file or directory

Any way to delete the directory with offending filename? If I attempt to delete the parent directory I get a "Directory not empty message"

5
  • That's … fascinating. What do you get if you run echo * | od -t ax1 in the offending directory? I am trying to find out something about the character encoding used here. If you find that the letter ů is encoded as c5 af, that should not have been possible, and it may explain the problem. By Apple's encoding rules for filenames, it should be 75 cc 8a instead. Jul 29, 2012 at 19:01
  • If you cannot solve this (I suspect that may be the final outcome) you can at least work around it by moving the problematic directory away to some dark corner of the filesystem where it won't bother you. Jul 29, 2012 at 19:42
  • Thanks for the tip on the encoding check. Here is what I got:scott@death-star { /Volumes/Storage Vault/Christina Aguilera } [!3106] -> echo * | od -t ax1 0000000 R a d i ? ? sp D i s n e y _ sp J 52 61 64 69 c5 af 20 44 69 73 6e 65 79 5f 20 4a 0000020 a m s sp V o l . sp 2 nl 61 6d 73 20 56 6f 6c 2e 20 32 0a 0000033 Jul 29, 2012 at 19:48
  • I do see the "c5 af". So for now until I decide to reformat the drive I'll just move it into a "dark corner" of my hard drive and ignore it. Jul 29, 2012 at 19:50
  • Unfortunately no. Deleting the parent directory via "rm -rf" returns a "Directory not empty message" Jul 29, 2012 at 20:01

2 Answers 2

3

If you look at this answer from Stack Overflow, you will learn that filenames on HFS must be in fully decomposed form, in which an accent on a letter is encoded separately from the letter itselves (and after the letter). In your case, the filename has somehow been snuck onto the filesystem in composed form instead, which confuses the filesystem to the point where it can see that the file is there, but still cannot find it. If Disk Repair cannot find and fix the problem, I much doubt that there is much you can do. There is an ancient File Name Encoding Repair Utility out there, but as it officially supports OS X 10.1 and 10.2 only, I would be rather hesitant about running it on a modern OS X if I were you. So your best bet is to hide the problematic directory somewhere it won't bother you.

1
  • Note that this is an ancient answer, dealing with HFS. Filename conventions on APFS are different: While filenames are usually on decomposed form, macOS these days can also deal with filenames on composed form reasonably well, on APFS. Mar 16, 2022 at 5:22
2

I had the exact same problem. Had a directory (on NAS) with special characters and tried to delete in OSX. First using Finder, then in bash command line. ls seemed to know the directory was there, but would say "No such file or directory" instead of listing the details. rm -rf on the parent directory would return "Directory not empty"

After much googling and messing around with no success, decided try another OS. Was able to see and delete the directory with no problems from my Windows laptop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .