I've never had this problem before, but for some reason, I can't rename my folder to packages/.

This is the structure:

  -  packages_old/
  -  packages

When I try to rename the folder with Thunar, I get an error message saying that the file already exists. Same with mv:

blender iso $ mv packages_old/ packages/
mv: accessing `packages/': Not a directory

Why am I unable to rename my file and folder to have the same name:

  -  packages/
  -  packages

I swear I've done this before.

  • 23
    Your memory is probably not as foolproof as you think it is. In the unix platform "everything is a file". You cannot have a file and folder with the same name because directories are just a special kind of file. It's related to the traditional .d extensions on directories in /etc. Suppose you did ls packages or vim packages -- how would the system know if you wanted the directory or the file?
    – jw013
    Oct 11, 2011 at 21:53
  • 2
    Could you maybe tell us what OS you're using? Because you cannot have a file and a directory have the same name on most OS I know
    – rahmu
    Oct 11, 2011 at 21:56
  • 2
    @j013, why have you answered in a comment and not wrote an answer?
    – andcoz
    Oct 11, 2011 at 21:58
  • 2
    You can't do it on Windows, either. On my Windows 7 machine, trying to do so yields the error: There is already a file with the same name as the folder name you specified. Specify a different name.
    – Chris Down
    Oct 11, 2011 at 22:19
  • 6
    In Windows, the default settings is to ignore extensions, so you could have a package directory and a package.txt file in the same folder. From Windows Explorer, it will appear that you have to entries called "package", when in fact, it is just hiding part of the filename of one.
    – Arcege
    Oct 12, 2011 at 0:48

2 Answers 2


In Unix, almost everything is a file. A directory is a special type of file that from the user's perspective can "contain" other files.

The error Not a directory occurs because your existing file is not a directory, and since a directory is a type of file, and there cannot be two identically named files in one directory, the operation cannot be performed.

  • 6
    As for your memory problem, maybe in the past your file and directory had the same name but with different case, like "package" and "Package". File names are case-sensitive, so that would work.
    – noamtm
    Oct 16, 2011 at 10:30

Because if you were able to do such a thing, life would be miserable for programmers like me when I try to iterate files in a directory.

For the following pseudocode:


Should the OS reply true or false?


You must log in to answer this question.

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