I'm using tkinter askdirectory to get a user selected folder name in Win 10.
For a directory called 'Documents Nig 30Jan2025' the code returns D:/Documents
for a directory on a usb attached drive. For other directories on the drive it returns the full directory name, eg
'Zipped folder 1'. If I rename the Documents folder eg to 'Documentx Nig 30Jan2025' the code still returns
D:/Documents
.
The code is :
from tkinter import filedialog as fd
from tkinter import Tk
dirOptions = {"title": "Select Directory","mustexist": True}
root = Tk(); root.withdraw()
folder = r'{}'.format(fd.askdirectory(**dirOptions))
print("folder - ",folder)
root.destroy()
I can't find why this is happening. Would appreciate how to get the full folder name. Thanks.
I tried selecting other folder names on the C and D drive and they all show the correct folder name.your text