4

When I try to move, rename, or delete a file named in Finder, I get this error message:

The operation can't be completed, because an unexpected error occured (error code -50).

With mv, rm or find -delete in Terminal

 rm: /Library/␀: Invalid argument
 mv: rename /Library/␀ to /tmp/␀: Invalid argument
 find: -delete: unlink(/Library/␀): Invalid argument

Can I move or delete this file in Mac OS X or do I have to use another operating system?

I even tried creating a file with this name in /tmp and it has not gone away since 8 reboots.

1
  • Have you tried using something other than a shell? E.g. Python's os module? May 7, 2018 at 3:56

4 Answers 4

8

You can attempt to remove the file by its inode number. List the files in /Library with the -i option

ls -il /Library

The first column is the inode number of the file. Then use find

find /Library -inum XXXXXXX -delete

where XXXXXX is the inode number of the file.

1
  • I don't know why my comment was deleted, but this just passes the filename to unlink, giving me the same "Invalid argument" error. Jan 31, 2016 at 1:58
4

This seems to be a 10.11 only problem, so it's impossible to delete on 10.11 at least, but you can very likely delete this on any OS X version other than 10.11, (I tried 10.4 and 10.10, and I could delete files with this character).

1
  • The bug is on the creation side. Otherwise many commands would fail on a Unix environment. For example find -print0, xargs...
    – dan
    Aug 18, 2016 at 6:07
0

Some newer macOS systems have trouble handling filenames that contain the "nul" character. The system interprets "nul" as the end of the filename, thus it cannot find the file. You could try to boot from another system, or use Target Disk mode and connect it to a Mac with an older macOS system (Mountain Lion etc.) Deleting it from recovery mode through the command line might work, or you could try fd0's inode number method.

1
  • There’s always going to be an inode to delete a file with a problematic file name. Probably far simpler than taking the filesystem to another os.
    – bmike
    May 7, 2018 at 2:14
-1
mkdir tmp; mv * tmp; cd tmp; mv [A-Z]* [a-z]* [1-3]* ..; rm *; cd ..; rmdir tmp
2
  • 1
    Welcome to Ask Different and thank you for your answer. :) Unfortunately, short answers such as this don't really provide enough detail or context to help many users. If possible, it'd be good if you could add some more info on what a user needs to do with your answer? Also, you may want to read How to Answer for tips on providing answers here.
    – Monomeeth
    May 7, 2018 at 4:00
  • 1
    As written it's even dangerous as the second mv command doesn't move all non-problematic files out of the tmp directory.
    – nohillside
    May 7, 2018 at 8:30

You must log in to answer this question.

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