9

Windows recognizes files using extensions. Does same applies to folders? Is there a special extension that mark a file as a folder?

2
  • 6
    The file name extension denotes a file type. A folder is not a type of file, it's a folder. Feb 21, 2012 at 14:39
  • 1
    -1 You click 'show extensions", and you don't see one for a folder. You never ever hear of any folder/directory having an extension. One would surely think it'd be mentioned somewhere on the internet if it did.
    – barlop
    Dec 12, 2015 at 19:39

8 Answers 8

9

There is no defined extension to a directory in Windows; rather, the type ("file" versus "directory") is kept in the master file table.

You should be able to see all files' extensions by just deselecting the "Hide extensions of known file types" in the folder options settings, or you can type command dir from the command line to see the files with extensions and you would see that the folder names do not have any extra extensions.

6
  • 1
    So you are saying there a type flag in file system that specifies whether a file is a normal file or folder ?
    – Serious
    Feb 21, 2012 at 14:57
  • The linux maintains a flag to differentiate between a regular file, a directory file, a character device file, a block device file, etc... Windows also should be maintaining something similar....
    – Mallik
    Feb 21, 2012 at 15:08
  • 7
    Pretty much all file systems keep such an attribute. Windows NTFS has a separate "DIRECTORY" flag in the MFT record, but the actual object type greatly depends on presence of named attributes; for example, a symbolic link can also have the "DIRECTORY" flag, but it has the $REPARSE_POINT attribute containing the target and lacks $INDEX_ALLOCATION which would otherwise contain the file names. Meanwhile, in Linux ext2/3/4 the "type" is simply part of the "permission bits" - 041777 is a directory with permissions 01777, and 0100644 is a regular file with permissions 0644. Feb 21, 2012 at 15:29
  • 2
    On the other hand, VMS (which could, in a way, be considered a parent of Windows NT) does have a special extension for directories -- .DIR -- and they can be managed very similarly to files; doing dir [.notes] just looks for a file named notes.dir in the default directory; one can even do type notes.dir to see the raw contents. (On Linux, converting a directory to a file cannot be done without resorting to debugfs or similar tools, and is damn near impossible on Windows NTFS. Some BSDs do still allow cat'ing directories, though.) Feb 21, 2012 at 15:35
  • (Disclaimer: Original research using debugfs and ntfsinfo. No guarantee of accuracy.) Feb 21, 2012 at 15:41
4

As others have said, Windows doesn't use filename extensions to identify folders. Folders, also called directories, are actually files but they have a FileAttribute value that identifies them as folders rather than regular files.

At a command prompt, you can type:

c:\temp> dir /a:d

which means, list all the files with the directory attribute, i.e., list of the folders in the current folder (c:\temp). Type dir /? for other options.

In Windows Explorer (for Windows Vista and Windows 7) you can specify a search filter of kind:folder to find the subfolders of the selected location.

There are other FileAttribute values, too; Archive, Compressed, Encrypted are some of the more common ones. You can use scripting and programming languages to examine these attributes. Here's a post on the Scripting Guys blog about using PowerShell to work with file attributes.

FWIW, although you can name a directory something like test.png, I think that's likely to create confusion. Windows won't care, but users might.

1
  • 1
    FWIW, physically, the "Directory" flag is stored separately in the MFT record flags, not as part of the "File attributes" field. Feb 21, 2012 at 15:18
2

Folders are a different type object. They don't have to have a extension to identify them as folders.

The name can consist of any valid characters and that includes ".", so you can call a folder:

test.txt
test.png
etc.

1

Note that the correct answers here notwithstanding, windows does in fact attempt to classify a folder by its contents and change the presentation based upon the classification.

This classification is called a Folder Type and windows has what is typically called Automatic Folder Type Discovery.

Unfortunately, sometimes merely dropping an mp3 file into a folder changes it's template to "music" even though the other 100 files are txt docs etc.: I don't need to rate my README.TXT as 5 stars with a run length of UNDEFINED.

Altering the behavior requires editing the registry, as far as a I know.

0

I wish somebody could know too the FOLDER ext. If there really is one like the recycle bin... You can make a folder and change it to recycle bin by adding without the quote ".{645FF040-5081-101B-9F08-00AA002F954E}" as its extension...

By this, you can confuse other users and if they try to open your folder (that is changed into recycle bin" they will never get to it instead they will be opening the recycle bin's contents... You can set it to HIDDEN also for another level of security...

Be sure to hide all don't forget that it's your system folders and extension after doing so....

Also NEVER FORGET THAT IT'S YOU FOLDER...

You can make a batch file for that certain purpose: just put this in notepad:

@echo off
ren FOLDER XFILES.{645FF040-5081-101B-9F08-00AA002F954E}
attrib +r +a +s +h XFILES.{645FF040-5081-101B-9F08-00AA002F954E}

SAVE THIS AS MODIFY.bat or BAT.bat, then to OPEN it for later use use this on another notepad or wordpad:

@echo off
attrib -r -a -s -h XFILES.{645FF040-5081-101B-9F08-00AA002F954E}
ren XFILES.{645FF040-5081-101B-9F08-00AA002F954E} FOLDER

SAVE THIS AS SHOW.bat of UNLOCK.bat.

0

Folder extensions are .dir. If you right-click a folder and go to Properties > General, it says Type: File Folder (.dir). However, making file with such extension does NOT make it a folder. Also, there is no .dir entry in HKEY_CLASSES_ROOT. Maybe that's because in NTFS, folders have special attribute that tells device that it's a folder and that (.dir) in folder are just for distraction, since it didnt say such thing in Windows XP.

1
  • 2
    Sadly, this is wrong. Notice that you can name a file file.dir and you can name a folder folder.dir. There's nothing special about the .dir extension whatsoever. May 3, 2017 at 13:56
0

A folder is not an object in the way that a file is. A file exists on disk (say) and has contents, and therefore a real size. A file also has an entry in the file table (of whatever filesystem type). A folder on the other hand is ONLY an entry in a file table, and is referenced as an attribute of the file. This is why folder sizes must be calculated in a fashion different from files.
Whereas a file actually exists (like a billiard ball), a folder is an abstraction (like the color of a billiard ball). A ball rolls, but the color blue does not.
This also why when you move a large file to a different file on the same disk it does not take time -- it is not moving to a different folder. It just has a single attribute changed in its file entry, assigning it do its new (but imaginary) folder.
Since files and folders are both listed in the file tables, however, there are attributes by which you can distinguish one from the other. But an extension is not one of them. Folders do not have an actual size (they calculate the size of everything assigned to that folder instead), and they do not have an extension.

-1

So many not actually answering yes or no... Let's try context. If an excel file has certain extension and attributes that define it as an excel file, beyond the MFT or other information areas of the disk, they define it separately from other files. A directory is a file list. What the original post is asking for is vague to say the least. But, I would like to know if there is any way to read that list, as in, what's in the directory. If a directory is 12kb on disk, it's a list of files or simply a blank file, but it does have some attributes that define it as such, making it easier to identify. Identifying these files could help in recovery situations, defining a naming scheme if filenames are in a list. If they are nothing but pointers, you have some information you can use. Either way, a more thorough understanding of what the original post wants is essential before any answer can be given.

All I can add is... ...YES directories are FILES on disk. NO they do not have a useable extension, but they do carry an extension of .dir in microsoft and dos based systems. What defines them as a folder other than any attribute is a key value in the file table. The extension is only used after that key value.

You must log in to answer this question.

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