May-21-2022, 09:01 PM
hi, I know I can get the name of the last folder using os.path.basename and os.path.normpath.
src_1 = "/storage/emulated/0/Documents/TAX/December_2021"
src_2 = "/storage/emulated/0/Documents/TAX/March_2022"
print(os.path.basename(os.path.normpath(src_1)))
gives me: December_2021
Nice.
HOWEVER, this doesn't work, if I use a "wildcard" as the last folder:
src = "/storage/emulated/0/Documents/TAX/{name of this folder}"
print(os.path.basename(os.path.normpath(src)))
I only get {name of this folder} and not December_2021 or March_2022.
Is there a way to do it this way or do I need another approach?
Thanks for any help!
src_1 = "/storage/emulated/0/Documents/TAX/December_2021"
src_2 = "/storage/emulated/0/Documents/TAX/March_2022"
print(os.path.basename(os.path.normpath(src_1)))
gives me: December_2021
Nice.
HOWEVER, this doesn't work, if I use a "wildcard" as the last folder:
src = "/storage/emulated/0/Documents/TAX/{name of this folder}"
print(os.path.basename(os.path.normpath(src)))
I only get {name of this folder} and not December_2021 or March_2022.
Is there a way to do it this way or do I need another approach?
Thanks for any help!