I am trying to get just the file name of the selected file in tkinter file dialog
Here's my code:
def browseFile(self):
root = tk.Tk()
root.withdraw()
file_path = askopenfilename(filetypes=(("Video files", "*.mp4;*.flv;*.avi;*.mkv"),
("All files", "*.*") ))
print file_path
What I am getting with this code is the whole path of the selected file, where I only need the file name. How can I do it?
results with my code:
C:/Users/Guest/vid1.mp4
what I want:
vid1.mp4