Ads

Check out value in brief website for more up-to-date content.

how to fetch file name without file extension ?

in bash script or linux terminal

%%bash

basename /home/abanoub/Work/hello.py .py

hello

in Python 3

%%pyhton3

from pathlib import Path

p = Path('/home/abanoub/Work/hello.py')

print(p.stem)

If you want to get new posts, make sure to subscribe to Value In Brief by Email.