File name? Path name? Base name? Naming standard for pieces of a path

file names list
in a file name the base name is the quizlet
file path
how to write a file path
path file name python
every file name has two parts
path filename python
filename or file name

I keep getting myself in knots when I am manipulating paths and file names, because I don't have a common naming system that I use.

I need to come up with a naming standard and stick to it, and I would like to be clear and consistent with others, so I am opening up to learn the canonical answers.

Consider this toy problem: (Windows example, but hopefully answer should be platform independent)

You have been given the full name of a folder: C:\users\OddThinking\Documents\My Source. You want to walk the folders underneath, and compile all the .src to .obj.

At some point you are looking at the following string.

C:\users\OddThinking\Documents\My Source\Widget\foo.src

So, what identifier names would you use for the parts?

A) foo
B) foo.src
C) src
D) .src
E) C:\users\OddThinking\Documents\My Source\ - i.e. the top of the tree.
F) Widget\foo.src - i.e. the path from the top of the tree to the leaf.
G) Widget - i.e. one node of the tree.
H) C:\users\OddThinking\Documents\My Source\Widget\ - i.e. the name of the folder
I) C:\users\OddThinking\Documents\My Source\Widget\foo.src

Let me give some answers, to get you started.

A) base name?

B) file name? Or is it filename? The difference is important when choosing identifier names, and I am never consistent here.

C) Extension

D) Extension. Wait, that is what I called C. Should I avoid storing the dot, and just put in in when required? What if there is no dot on a particular file?

H) path name? Or wait, is it just the path?

I) filename. Wait, that is what I called C. Path. Wait, that is what I called H. Maybe H should be the folder name. Isn't "folder" a Windows-specific term, though?

I think your search for a "standard" naming convention will be in vain. Here are my proposals, based on existing, well-known programs:

A) C:\users\OddThinking\Documents\My Source\Widget\foo.src

Vim calls it file root (:help filename-modifiers)

B) C:\users\OddThinking\Documents\My Source\Widget\foo.src

file name or base name

C) C:\users\OddThinking\Documents\My Source\Widget\foo.src (without dot)

file/name extension

D) C:\users\OddThinking\Documents\My Source\Widget\foo.src (with dot)

also file extension. Simply store without the dot, if there is no dot on a file, it has no extension

E) C:\users\OddThinking\Documents\My Source\Widget\foo.src

top of the tree No convention, git calls it base directory

F) C:\users\OddThinking\Documents\My Source\Widget\foo.src

path from top of the tree to the leaf relative path

G) C:\users\OddThinking\Documents\My Source\Widget\foo.src

one node of the tree no convention, maybe a simple directory

H) C:\users\OddThinking\Documents\My Source\Widget\foo.src

dir name

I) C:\users\OddThinking\Documents\My Source\Widget\foo.src

full/absolute path

Filename, Naming Conventions; Short vs. Long Names. Paths. Fully Qualified vs. 8 characters for the base file name and 3 characters for the extension, for a This works because COM1–COM9 are part of the reserved names in the� Path name? Base name? Naming standard for pieces of a path. 795. How to get full path of a file? 1099. Download a single folder or directory from a GitHub repo. 5.

Good question first of all, my +1. This thing bugged me when I had to create a slew of functions in Utility class once. GetFileName? or GetFullName? GetApplicationPath means full path or the directory name? and so on. I come from .NET background, so I think I can add little more to otherwise excellent answer by @blinry.

Summary: (In italics is what I would not use as a programmer)

  1. Path: Path specifies a unique location in the file system (unless its relative path). Path name is less often used, but I would stick with path - it pretty much explains what it is. Path can point to a file or a folder or even nothing (C:\). Path can be:

    1. Relative Path: My Source\Widget\ is relative path as well as Widget\foo.src. Self explanatory.
    2. Absolute Path or Full Path: Is the fully qualified path that points to the target. I tend to use the latter more often. C:\users\OddThinking\Documents\My Source\Widget\foo.src is hence full path. See at the end what I call full path that points to a file and that ends as a directory.

    The wiki page and .NET naming for path is consistent.

  2. Root Path or Root Directory: Former is .NET convention while latter is more heard in UNIX circles. Though I like both I tend to use the former more. In windows, unlike UNIX, has many different root paths, one for each partition. Unix systems have one root directory which holds information on other directories and files. Eg. C:\ is root path.

  3. Folder or Folder Name: Widget, OddThinking etc in your case. This might be a Windows only convention (in fact its my own odd thinking :)), nevertheless I strongly object to blinry`s answer "Directory". Though for a normal user directory means the same as a folder (like subfolders, subdirectories), I believe from a technical angle "directory" should sound like a qualified address to the target and not the target itself. More below.

    1. Sub Folders: With respect to users OddThinking and Documents are sub folders.
    2. Sub Directories: With respect to users OddThinking\, OddThinking\Documents\ and OddThinking\Documents\My Source\Widget\ are sub directories. But we do not often need to bother about it, do we?
    3. Child Folder: With respect to users OddThinking is a child folder (as well as sub folder)
    4. Parent Folder: For OddThinking users is its parent folder (Just mentioning different terminologies, no big deal).
  4. Directory or Directory Name: The former to use generally in real life, the latter to be in code. This refers to the fully qualified path (or simply full path) till the target's parent folder. In your case, C:\users\OddThinking\Documents\My Source\Widget (Yes a directory is never meant to point to a file). I use directory name in my code since directory is a class in .NET and Directory Name is what the library itself calls it. Its quite consistent with dirname used in UNIX systems.

  5. File Name or Basename: Name of the file along with extension. In your case: foo.src. I would say that for a non technical use I prefer file name (it is what it means for an end user) but for technical purposes I would strictly stick with basename. File Name is often used by MS, but I am surprised how they are not consistent not just in documentation but even in library. There filename could mean either basename or full path of the file. So I favour basename, that's what I call them in code. This page on wiki too says file name could mean either full path or the basename. Surprisingly even in .NET I can find the usage basename to mean the root name of the file.

  6. Extension or Filename Extension or File Extension: I like the last one. All refers to the same thing but what is it is again a matter of debate! Wiki says it is src while back then I remember reading that many of the languages interprets it as .src. Note the dot. So once again my take is, for casual uses it doesn't matter what it is, but as a programmer I always see extension as .src.

    Ok I might have tried to fetch some standard usages, but here are two of my conventions I follow. And it is about full paths.

    1. I generally call a full path that point to a file as file path. To me file path is clear cut, it tells me what it is. Though with file name I find it as the name of the file, in my code I call it file name. It's also consistent with "directory name". From the technical side, name refers to the fully qualified name! Frustratingly .NET uses the term file name (so I have my case here) and sometimes file path for this.

    2. I call a full path that ends as a directory a directory. In fact one can call any piece of address that doesn't point to a file a directory. So C:\users\OddThinking\Documents\My Source\ is a directory, C:\users\OddThinking\ is a directory, or even OddThinking\Documents\My Source\ (better to call it sub directory or even better relative path - all that depends on the context you are dealing with it). Well above I mentioned something different about directory which is directory name. Here is my take on it: I'll get a new path to avoid confusion. What is this D:\Fruit\Apple\Pip\? A directory. But if the question is what is the directory or even better directory name of D:\Fruit\Apple\Pip\, the answer is D:\Fruit\Apple\. Hope its clear.

    I would say it's better not to worry about the final two terms as that is what create the most confusion (for me personally). Just use the term full path!

To answer you:

  1. with respect to the path you have given

    A) No idea. Anyways I never needed to get that one alone.

    B) basename

    C) I would just call it file extension for time being, I am least worried since I never needed that alone to be named in my code.

    D) file extension surely.

    E) I do not think this is a general purpose requirement. No idea. In .NET base directory is the same as directory name.

    F) relative path

    G) folder (parent folder to basename foo.src)

    H) directory name

    I) full path (or even file name)

  2. in general (sorry for being a bit verbose, just to drive the point home) but assuming foo.src is indeed a file

    A) NA

    B) basename

    C) NA

    D) extension

    E) directory or simply path

    F) relative path

    G) NA

    H) directory or simply path

    I) full path (or even file name)

Further driving with one example from my side:

  1. Consider the path C:\Documents and Settings\All Users\Application Data\s.sql.

    1. C:\Documents and Settings\All Users\Application Data\s.sql is the full path (which is a file name)
    2. C:\Documents and Settings\All Users\Application Data\ is the directory name.
  2. Now consider the path C:\Documents and Settings\All Users\Application Data

    1. C:\Documents and Settings\All Users\Application Data is the full path (which happens to be a directory)
    2. C:\Documents and Settings\All Users is the directory name.

Two tips of mine:

  1. I follow this rule of thumb that when it comes to addressing a full address irrespective of its type, I almost always call it "full path". This not only eliminates the use of two terminologies for file path and folder path, it also avoids the potential confusion if you are going to name that of file as file name (which for most users right away translates to basename). But yes if you have to be specific about the type of path, its better to name then file name or directory instead of more generic "path".

  2. Whatever it is you would have your own idea in mind, be consistent with it throughout. Have a consensus among team members that this means this and not that.

Now that just from the circle I have some practice. A new brand of terms would be what is used on OS X and android machines. And all these are just about physical paths in filesystem. A whole new set of terminologies would arise in case of web addresses. I expect someone to fill the void in this same thread :) I would be glad to hear the convention with which you have went ahead..

11.1. os.path — Common pathname manipulations — Python 3.3.7 , This section describes the file naming conventions used by the supported It can be the name of a file on disk, optionally including a drive and/or path joining together its component parts; that is, the path-name, base-name and extension. Please I want to make a macro in Excel 2010 than the user can save a file in a specific folder but the name of the file would be given by default, can not be changed by the user. This for avoid that the user click other file looking the specific folder to save the file and the name of it change.

Naming Files, Paths, and Namespaces, Pathname represents the name of a file or directory on the filesystem, but not the This library works with pathnames of local OS, however non-Unix pathnames is to manipulate file path information in a neater way than standard Ruby provides. pn.dirname # Pathname:/usr/bin base = pn.basename # Pathname: ruby dir,� The file will have a certain name e.g., where the XXXXXX will change. Since the folder will have different files populated e.g., with similar naming, I would only want to watch for the first files being placed. How can I filter this here? Here is a look at the code:

Python's pathlib standard library has a great naming convention for path components:

a) C:\users\OddThinking\Documents\My Source\Widget\foo.src


b) C:\users\OddThinking\Documents\My Source\Widget\foo.src


c) C:\users\OddThinking\Documents\My Source\Widget\foo.src (without dot)


d) C:\users\OddThinking\Documents\My Source\Widget\foo.src (with dot)


e) C:\users\OddThinking\Documents\My Source\Widget\foo.src

grand parent path

f) C:\users\OddThinking\Documents\My Source\Widget\foo.src

relative path to grand parent path

g) C:\users\OddThinking\Documents\My Source\Widget\foo.src

parent name

h) C:\users\OddThinking\Documents\My Source\Widget\foo.src

parent path

i) C:\users\OddThinking\Documents\My Source\Widget\foo.src


File Naming, basename — Returns trailing name component of path a string containing the path to a file or directory, this function will return the trailing name component. There is only one variant that works in my case for my Russian UTF-8 letters: language agnostic - File name? Path name? Base name? Naming standard for pieces of a path . I keep getting myself in knots when I am manipulation paths and file names, because I don't have a common naming system that I use. I need to come up with a naming standard and stick to it, and I woul…

No you're not crazy.

In Windows systems, sometimes the path of the directory containing the file is called path, which is how it was from the beginning. So, for example,


        PATH:  x:\dir1\dir2
        FILE:  myfile.txt

        PATH:  /dir1/dir2/myfile.txt
        FILE:  myfile.txt

The Unix/Linux approach is a lot more logical, and that's what everyone mentioned above: path including the file name itself. However, if you type "call /?" in the Windows command line, you get this:

    %~1         - expands %1 removing any surrounding quotes (")
    %~f1        - expands %1 to a fully qualified path name
    %~d1        - expands %1 to a drive letter only
    %~p1        - expands %1 to a path only
    %~n1        - expands %1 to a file name only
    %~x1        - expands %1 to a file extension only

So there it is, "path only" and "file name only". At the same time, they refer to the whole string as "fully qualified path name" which is understood as drive letter plus path plus file name. So there's no real truth. It's futile. You've been betrayed.


To answer your question

This is how I'd name your examples:

A: -
B: basename
C: extension
D: -
E: -
F: -
G: -
H: pathname (or dirname or containing path)
I: full name

A-D-E-F have no simple nicknames. And since php is probably the most widely known cross-platform language, everyone understands "basename" and "dirname" so I'd stick with that naming. Full name is also obvious; full path would be a bit ambiguous but most of the time it means the very same thing.

class Pathname - Documentation for Ruby 2.1.0, File::Basename - Parse file paths into directory, filename and suffix. NOTE: dirname() and basename() emulate the behaviours, and quirks, of the shell and C the dirname(1) shell function which is subtly different from how fileparse() works. ResourceManager(String, Assembly) looks up resources based on two pieces of information that you supply: the base name of the .resources file, and the assembly in which the default .resources file resides. The base name includes the namespace and root name of the .resources file, without its culture or extension.

basename - Manual, Therefore, Emacs considers a file name as having two main parts: the part of filename , as a directory name (see Directory Names), or nil if filename does not� Many of our naming instructions mention having Optional_Info at the end of the file name. As the label suggests, it’s optional, but many people like to use it for things such as an episode title; such optional info is ignored by Plex when matching content. We use .ext as a generic file extension in the naming/organizing instructions. You

File::Basename, A path is a slash-separated list of directory names followed by either a in a directory name) E:\Data\MyStuff\roads.shp (path terminating in a file name) Catalog paths consist of two parts: the workspace and the base name, as illustrated below: and backward slashes to the appropriate operating system convention. These elements could include things like the date of creation, author's name, project name, name of a section or a sub-section of the project, the version of the file, etc. An advantage to using unique and standardized filenames is the ability to follow path names and link to other systems that require unique filenames.

File Name Components, the o/p file must be in “xxxx_ddmmyy_HH:SS.txt” the o/p creates problem since the ” : ” used in naming a txt file.(ie HH:MM) so is there any way of changing the time format like HH.MM or HH-MM. i need both time & date in the txt file name. so how to proceed

  • Mike Pope, a technical editor at Microsoft, points out on his blog that that while the Microsoft style guide sticks consistently to two words: file name, folder name, volume name, the Apple Style Guide sometimes joins them: filename, pathname, volume name.
  • A) should definitely not be called basename because basename is already used in many places to mean the last item in a path (for a file, that would be the filename without dirpath). Some places call the filename without extension the stem.
  • Also, for files with multiple periods (e.g., foo.src.txt) , is there any standard way of identifying (and naming) the extension/s?
  • It's getting off-topic, but be careful with the storage of the extension separate to the dot. You need to handle file names of "foo", "foo." and "foo.txt" (and even "foo.txt.bak".)
  • hi guys, great example. It would be more easy to read if you put the answer next to the question, instead of using references that forces to scroll up. I make an edit by the way in order to improve that. Grettings
  • Victor, since your edit got rejected (wtf guys, this is a very good improvement!) I just did it myself :-)
  • For 1. (file name only without extension), I decided to go with File Title a long ago due to the lack of a clear convention or at least a global consensus.
  • For A (filename without extension), you could use stem. References: ,… ,…
  • For a long time I've been using the word "pathname" to mean the entire absolute path including the full filename. Your answer, others here, and resources elsewhere have changed my mind about that, and now i'll use the word "fullpath" for this, "path" for the location without filename, and "filename" or "name" for the filename itself.
  • What do they call the entire thing then? path, fullpath?
  • @wisbucky The entire thing is called "path" in their nomenclature.
  • @wisbucky Fixed the link. Thanks.
  • @olibre: Thanks for the C++17 update. But stem() is a part of the filename, not the path.
  • @johnc.j. It's too bad Boost.Filesystem wasn't as well known when the question was first asked. I'd rather adopt the nomenclature of a peer-reviewed library than make something up on my own.
  • For a long time I've been using the word "pathname" to mean the entire absolute path including the full filename. Other answers here and resources elsewhere have changed my mind about that, and now i'll use the word "fullpath" for this, "path" for the location without filename, and "filename" or "name" for the filename itself.