I accidentally named a file testIn2Post.py rather than testIn2post.py (notice the different case for the letter "p") and have been unable to rename it, even after rm-ing the file in question. Notice that when I recreate the file with a lowercase "p" and then run ls, the file is created with a capital "p":

enter image description here

I expected to create a filename testIn2post.py, but I get testIn2Post.py (again, different case for the letter "p").

How can I force OS X to properly rename/create my file? It is causing issues when I try to import the module.

  • 5
    It would be inmensly useful if you show the actual error message when you try to rename/delete the file. – Braiam Nov 2 '14 at 4:20
  • 3
    What filesystem are you using? Unlike Linux, OSX normal filesystem is case-insensitive, is it not? If so, then testIn2Post.py and testIn2post.py are the same file. – John1024 Nov 2 '14 at 4:31
  • 1
    @Braiam as you can see from the image, there is no error message, just the wrong filename after touching (look carefully and see the difference in casing on the p' – Anthon Nov 2 '14 at 7:56
  • @John1024, I figured OS X's case insensitivity was the source of the issue and am looking for a solution to this "caching" of the original name. – gwg Nov 2 '14 at 14:59
  • 1
    @Braiam If you create a file by touch abc in an empty directory and then do ls and see a filename xyz you think that is normal? Not an error condition? – Anthon Nov 2 '14 at 17:29

There might be simpler ways, but when I have encounterd the Mac's filesystem to behave against my (Unix) expectations I moved the files that I need to a new directory, remove the old one and renamed the new directory to the old one.

cd ..
mkdir tmptest
mv test/*.py tmptest
rm -rf test
mv tmptest test

I am not sure what causes this except that it probably has to do with the underlying filesystem not being case-sensitive as John1024 already commented. It never happened often enough to me to care about finding a more efficient solution than this workaround.

  • Okay, this worked. I actually just mv-ed the file down a directory and then back up. – gwg Nov 2 '14 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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