TransWikia.com

How do you call the "happy-dog" part of file "happy-dog.png"?

Unix & Linux Asked on November 19, 2021

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 Answers

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.

Answered by Gilly on November 19, 2021

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.

Answered by Stéphane Chazelas on November 19, 2021

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.

UPD: linguistics often use "stem" in a vast sense "part before ending and, sometimes, before suffix". But I see mention for "root" in neighbor reply, so, seems "root" is good until you need further distinction.

Answered by Netch on November 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP