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.

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

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.

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

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).

  • The bug is on the creation side. Otherwise many commands would fail on a Unix environment. For example find -print0, xargs... – daniel Azuelos Aug 18 '16 at 6:07

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.

  • 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 at 2:14
mkdir tmp; mv * tmp; cd tmp; mv [A-Z]* [a-z]* [1-3]* ..; rm *; cd ..; rmdir tmp

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 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 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 at 8:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.