14 lines
398 B
Python
14 lines
398 B
Python
import os
|
|
import re
|
|
|
|
file_path = "../../../../Downloads/images/352405884025RAVGMC.jpg"
|
|
|
|
# Using regular expression to extract the filename without extension
|
|
pattern = re.compile(r'/([^/]+)\.[a-z]+$', re.IGNORECASE)
|
|
match = pattern.search(file_path)
|
|
|
|
if match:
|
|
extracted_file_name = match.group(1)
|
|
print(extracted_file_name)
|
|
else:
|
|
print("Unable to extract filename from the given path.") |