There should be something elegant in Linux API/POSIX to extract base file name from full path
split() method in Python is used to Split the path name into a pair head and tail. Here, tail is the last path name component and head is everything leading up to that. In the above example 'file. txt' component of path name is tail and '/home/User/Desktop/' is head.
Use the GetFileName Method to Extract the Filename From a Path in PowerShell. The GetFileName method of the . NET's Path class returns the file name and extension of the specified path. The following example displays the file name and extension from the path C:\pc\test_folder\hello.
See char *basename(char *path)
.
Or run the command "man 3 basename
" on your target UNIX/POSIX system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With