When would the "." and ".." entries in a dir listing differ? (I understand they represent two different directories, but they always list identically with the same date and time in a default dir command. Do they ever differ?)

  • 1
    Can you give an example (perhaps with a screen shot) – ChrisF Sep 13 '11 at 20:05

As to the actual listing:

27/08/2011  11:23    <DIR>          .
27/08/2011  11:23    <DIR>          ..

They're using the date of the current directory for both. If you start in C:\Users\Chris (say) you might get the above. But when you go up to C:\Users you get:

26/07/2011  21:20    <DIR>          .
26/07/2011  21:20    <DIR>          ..

So the date of .. in the first case is not the same as the date of . in the second. Which is apparently wrong as they are (or should be) the same directory. However, . and .. are references to the current and parent directory and are both created at the same time - when the directory was created - so it's actually correct (thanks to Synetech inc for pointing this out)

The only time the timestamps would be different is if one or other of . or .. were recreated.

The original answer:

. means the current directory.

.. means the parent directory.

So under normal circumstances they are always different.

The only time they yield the same result is when you are at the root of the disk. So at C:\> dir . and dir .. produce the same output.

| improve this answer | |
  • answer to the point, great. – ppuschmann Sep 13 '11 at 19:11
  • Edited to emphasize the question is regarding their appearance in a dir listing. – Witness Protection ID 44583292 Sep 13 '11 at 20:05
  • @mike - tried to answer the revised question to justify the votes ;) – ChrisF Sep 13 '11 at 20:15
  • 4
    That’s wrong, because .. not given the timestamp of the parent directory, it is given the timestamp of the current directory. This is because . and .. are both created when the directory is created. – Synetech Sep 13 '11 at 22:06
  • @Synetech - Ah! The penny drops – ChrisF Sep 13 '11 at 22:09

No, they will always be the same. Because these are directories, not files, they are handled slightly differently (in fact, they are not even normal directories, they are pointers as eL01 said, so they are handled even more differently than normal directories).

When you create a directory, two entries are automatically created:

  • . points to the newly created directory
  • .. points to the the new directory’s parent

Obviously . will have the current date and time that the directory is created, and while it may seem logical for the timestamp of the parent directory to be copied to .., that is not how it works. When you create a new directory, both of the pointers receive the current date and time. This is the case from DOS through Windows 7 on both FAT* and NTFS.

| improve this answer | |
  • 1
    +1 since it seems you were the one coming up with the answer ChrisF is now presenting ;-) – Jonas Heidelberg Sep 13 '11 at 22:40
  • @Jonas, actually, ChrisF’s answer makes the same mistaken assumption that most people would: that .. would have the timestamp of the parent. (I would not be surprised if some day, a new file-system—WinFS?—were to finally do it that way). – Synetech Sep 13 '11 at 23:01
  • Starting with his 4th revision I'd say he doesn't make that assumption any more. – Jonas Heidelberg Sep 13 '11 at 23:15
  • @Jonas, ah okay. I didn’t see the edits. Oh well, he’s getting new up-votes anyway; I guess that’s the point to the edit function. – Synetech Sep 14 '11 at 2:23
  • I should have credited you in that latest revision - I'll do so now. – ChrisF Sep 14 '11 at 8:04

I actually can't give you proof, but I think: Every directory has a list of directories and files it contains. To make it possible to use relative paths every directory needs those two pointers - one to itself . and the other directory one level above .. - those two pointers are just created on the time the directory itself is created.

So the timestamp of .. is actually not the timestamp of the directory above but the timestamp of the pointer to the directory above.

| improve this answer | |
  • That is correct. The .. entry is given the timestamp of the current date and time when the current directory is created. – Synetech Sep 13 '11 at 22:06

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.