You could just .split it:

>>> Path('logs/date.log.txt').stem.split('.')[0]
'date'

os.path works just as well:

>>> os.path.basename('logs/date.log.txt').split('.')[0]
'date'

It passes all of the tests:

In [11]: all(Path(k).stem.split('.')[0] == v for k, v in {
   ....:     'a': 'a',
   ....:     'a.txt': 'a',
   ....:     'archive.tar.gz': 'archive',
   ....:     'directory/file': 'file',
   ....:     'd.x.y.z/f.a.b.c': 'f',
   ....:     'logs/date.log.txt': 'date'
   ....: }.items())
Out[11]: True
Answer from Blender on Stack Overflow
🌐
Python
docs.python.org β€Ί 3 β€Ί library β€Ί pathlib.html
pathlib β€” Object-oriented filesystem paths
February 23, 2026 - Create a new path object of the same type by combining the given pathsegments. This method is called whenever a derivative path is created, such as from parent and relative_to(). Subclasses may override this method to pass information to derivative paths, for example:
🌐
Python.org
discuss.python.org β€Ί ideas
Add pathlib.Path.stems - Ideas - Discussions on Python.org
April 20, 2023 - Path.suffix is to Path.stem as Path.suffixes is to …? >>> from pathlib import Path >>> p = Path("CurveFile.vs2022.vcxproj") >>> p.suffix '.vcxproj' >>> p.stem 'CurveFile.vs2022' >>> p.suffixes ['.vs2022', '.vcxproj'] While you can programmatically get each and every suffix, currently, there is no way to extract first part ('CurveFile') without doing string manipulation.
🌐
Mopicmp
mopicmp.github.io β€Ί python-pathlib β€Ί path-stem.html
Path.stem - Python Pathlib | BetterDocs
Example 1 From rht/eigen-neovim (eigen_neovim/github_client.py) Copy Β· for filepath in output_dir.glob("*.lua"): if filepath.name.endswith(".meta"): continue # Filename format: owner__name.lua stem = filepath.stem if "__" in stem: owner, name = stem.split("__", 1) cached.add(f"{owner}/{name}") return cached def fetch_configs( self, query: str = "filename:init.lua path:nvim", max_repos: int = 500, progress_callback=None, ) -> Iterator[ConfigFile]: """ Fetch Neovim configurations from GitHub.
🌐
Real Python
realpython.com β€Ί python-pathlib
Python's pathlib Module: Taming the File System – Real Python
January 11, 2025 - You’re using .with_stem() to create the new filename without changing the extension. The actual copying takes place in the highlighted line, where you use .read_bytes() to read the content of source and then write this content to destination using .write_bytes(). While it’s tempting to use pathlib for everything path related, you may also consider using shutil for copying files.
🌐
DataCamp
datacamp.com β€Ί tutorial β€Ί comprehensive-tutorial-on-using-pathlib-in-python-for-file-system-manipulation
How to Use Python's Pathlib (with Examples) | DataCamp
May 22, 2024 - The with_stem() method returns a file path with a different filename (although the suffix stays the same).
🌐
freeCodeCamp
freecodecamp.org β€Ί news β€Ί how-to-use-pathlib-module-in-python
Python Path – How to Use the Pathlib Module with Examples
May 10, 2022 - The .with_name() method doesn't change the name of the last component permanently. Also, if the given path doesn't contain a name, an error occurs as mentioned in the official documentation. PurePath().with_stem() changes only the name of the final component of the path:
Find elsewhere
🌐
OneUptime
oneuptime.com β€Ί home β€Ί blog β€Ί how to use pathlib for file paths in python
How to Use pathlib for File Paths in Python
January 27, 2026 - # path_components.py # Accessing different parts of a path from pathlib import Path path = Path("/home/user/project/data/report.csv.gz") # Name - final component print(f"Name: {path.name}") # report.csv.gz # Stem - name without final suffix print(f"Stem: {path.stem}") # report.csv # Suffix - final extension print(f"Suffix: {path.suffix}") # .gz # Suffixes - all extensions print(f"Suffixes: {path.suffixes}") # ['.csv', '.gz'] # Parent - immediate parent directory print(f"Parent: {path.parent}") # /home/user/project/data # Parents - all ancestor directories for parent in path.parents: print(f" {
🌐
PyTutorial
pytutorial.com β€Ί python-pathlibstem-explained-file-path-manipulation
PyTutorial | Python Pathlib.stem Explained | File Path Manipulation
March 23, 2025 - For example, you can use with_suffix() to change the file extension after extracting the stem. ... from pathlib import Path # Create a Path object file_path = Path("/documents/report.txt") # Change the suffix new_path = file_path.with_suffix(".pdf") ...
🌐
IONOS
ionos.com β€Ί digital guide β€Ί websites β€Ί web development β€Ί python pathlib
How does Python pathlib work and what are its benefits?
June 18, 2025 - from pathlib import Path md_path = Path("/Users/name/folder/blue.md") txt_path = md_path.with_name("red.txt") md_path.replace(txt_path)python Β· Even if Path itself does not have a method for copying, you can use .with_stem() to duplicate a file. This creates a new file name without changing the file extension. This is an example of the apΒ­proΒ­priΒ­ate code:
🌐
Rednafi
rednafi.com β€Ί home β€Ί python β€Ί no really, python's pathlib is great
No really, Python's pathlib is great | Redowan's Reflections
December 30, 2025 - We’ll linearly traverse through the tree and provide necessary examples to grasp their usage. Path β”‚ β”œβ”€β”€ Attributes β”‚ β”œβ”€β”€ parts β”‚ β”œβ”€β”€ parent & parents β”‚ β”œβ”€β”€ name β”‚ β”œβ”€β”€ suffix & suffixes β”‚ └── stem β”‚ β”‚ └── Methods β”œβ”€β”€ joinpath(*other) β”œβ”€β”€ cwd() β”œβ”€β”€ home() β”œβ”€β”€ exists() β”œβ”€β”€ expanduser() β”œβ”€β”€ glob() β”œβ”€β”€ rglob(pattern) β”œβ”€β”€ is_dir() β”œβ”€β”€ is_file() β”œβ”€β”€ is_absolute() β”œβ”€β”€ iterdir() β”œβ”€β”€ mkdir(mode=0o777, parents=False, exist_ok=False) β”œβ”€β”€ open(mode='r', buffering=-1, encoding=None, ...) β”œβ”€β”€ rename(target) β”œβ”€β”€ replace(target) β”œβ”€β”€ resolve(strict=False) └── rmdir()
🌐
GitHub
github.com β€Ί python β€Ί cpython β€Ί issues β€Ί 114610
`pathlib.PurePath.with_stem('')` promotes file extension to stem Β· Issue #114610 Β· python/cpython
January 26, 2024 - 3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ... The with_stem() call should raise ValueError, as it's impossible for a filename to have an empty stem and a non-empty suffix.
Author Β  barneygale
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί get-filename-from-path-without-extension-using-python
Get filename from path without extension using Python - GeeksforGeeks
October 3, 2025 - Python Β· import pathlib path = 'D:\\home\\Riot Games\\VALORANT\\live\\VALORANT.exe' name = pathlib.Path(path).stem print(name) Output: VALORANT Β· Explanation: Path(path).stem returns the filename minus its extension.
🌐
Iditect
iditect.com β€Ί faq β€Ί python β€Ί clean-way-to-get-the-quottruequot-stem-of-a-path-object-in-python.html
Clean way to get the "true" stem of a Path object in python?
In Python, if you want to obtain the "true" stem of a Path object (the stem without any file extension), you can use the stem attribute provided by the pathlib module. The stem attribute returns the name of the file or directory without its suffix. ... from pathlib import Path # Example Path ...
🌐
Readthedocs
autoclasstoc.readthedocs.io β€Ί en β€Ί latest β€Ί examples β€Ί pathlib.html
pathlib.Path β€” autoclasstoc 1.7.0 documentation
The snippet below shows how autoclasstoc can be used to document the pathlib.Path class from the Python standard library. This example also includes inheritance.
🌐
Python Morsels
pythonmorsels.com β€Ί pathlib-module
Python's pathlib module - Python Morsels
November 18, 2024 - Nearly every utility built-in to Python which accepts a file path will also accept a pathlib.Path object. For example the shutil library's copy and move functions accept pathlib.Path objects:
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί pathlib-module-in-python
Pathlib Module in Python - GeeksforGeeks
1 week ago - Depending on system Python is running on, Path will behave like either PosixPath or WindowsPath. Example: This code imports Path and creates a concrete path object using Path('/usr/local/bin'), which represents a real path in file system.