May-21-2022, 09:01 PM
(This post was last modified: May-21-2022, 09:06 PM by Gribouillis.)
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!
Gribouillis write May-21-2022, 09:06 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.