6

I just realized I don't know how file is called in file.ext.

The whole file.ext is called a file or filename, ext is called extension but how do you call the file part itself of file.ext?

For example happy-dog.png. All the file/filename is happy-dog.png, extension is png but how do you call happy-dog?

It's not basename. Is it like titlename? Or filepart? Any ideas?

  • 3
    Why not basename? There's even a command basename: Try this at your prompt basename happy-dog.png .png or basename dir/happy-dog.png .png. – RobertL Dec 1 '15 at 6:30
  • @RobertL in most shells this will return happy-dog.png again, without separating a part. – Netch Dec 1 '15 at 6:31
  • @Netch Maybe questioner is correct, it's not basename? I always thought of it as the base name, but I could be wrong! – RobertL Dec 1 '15 at 6:34
  • 1
    Isn't it suffix and prefix? – We are Borg Dec 1 '15 at 9:59
5

I doubt there is a stable terminology here. A small googling exposes people utilize base name for this, but this usage conflicts with the same term used as "full file name without path". For example, https://stackoverflow.com/questions/2183486/ exposes the case when "filename" is "basename" plus "extension".

OTOH, the term "extension" you use is weird. It's originated in CP-M/Dos/Windows world (distorting imitation of RSX-11/RT-11 approach) where a file name could (before Windows 95) have a single part after dot. In Unix world, this was named "suffix" from the very beginning, and I would strongly suggest you using this term. The difference is that multiple suffixes can exist - for example, a.o.d is dependency list for a.o. In turn, if this is suffix, the part before suffixes is a filename root. In my opinion, there is too small chance to get it conflicting with "root" as Unix superuser.

  • Note that for ODS-2, the on-disk filesystem layout used by the VMS operating system, the "extension" was actually a separate part of the inode-moral-equivalent ("file header", I think). I'm pretty sure that was the case for MS-DOS "FAT" filesystems, and I believe it's still the case for NTFS, which is a whole lot like ODS-2 on disk. – Bruce Ediger Dec 1 '15 at 16:35
1

csh, tcsh,vim and zsh which have an operator to extract that part of the file name ($file:r) call it the root name or root of the file name (well, $file:r applied to /foo/bar.baz is /foo/bar, so bar would rather be the root of the basename or the basename of the root). Erlang also has a rootname() operator and the python documentation also refers to the file path without the extension as the root.

That may not be very common practice (I long thought myself r was for rest of the file name and web search engines don't bring up a lot of references) but that's a long-standing one since that feature was already there and documented as such in the first publicly released version of csh in 1979.

1

I quite like Python's pathlib terminology of stem. This is consistent with natural language processing terminology, but I don't believe this is universal.

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.