Jun-13-2021, 03:45 AM
Greetings!
I'm trying to remove a bunch of test files using 'glob'.
I thought I could do it like this:
I'm trying to remove a bunch of test files using 'glob'.
I thought I could do it like this:
prod_tod_to_Rem = glob.glob("C:/0001/**/*.txt", recursive=True) dev_tod_to_Rem =glob.glob("C:/04/**/*.txt",recursive=True) rm_lst = [prod_tod_to_Rem,dev_tod_to_Rem] tor = [str(i) for i in rm_lst] print(tor) try: os.remove(tor) print (f" Removing TXT Flies --> {tor}") except OSError as e: print("Error: CANNOT Remove TXT file -->>", e )for some reason this part of the snippet not converting the list element to a string.
tor = [str(i) for i in rm_lst]Thank you.