Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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.

share|improve this question
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 '11 at 21:53
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 '11 at 21:56
@j013, why have you answered in a comment and not wrote an answer? – andcoz Oct 11 '11 at 21:58
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 '11 at 22:19
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 '11 at 0:48

2 Answers 2

up vote 22 down vote accepted

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.

share|improve this answer
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 '11 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?

share|improve this answer
It should just return 'both'. – Anthon Apr 2 at 4:47
isAlive("Schrödinger’s cat")   :-) – G-Man Apr 2 at 22:58
@G-Man Type boolean expected, got object (promise). – Scott Yang May 6 at 17:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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