I'm coding an interface with Tkinter and I want to automate a task. The actual function opens a window that allows the user to select files (I specify the type of files. Then the paths of these files are retrieved from other functions to modify the files. Here is my actual function:
def get_path(): #return the path of the selected file(s)
root = Tk()
i= datetime.datetime.now()
day = i.day
month=i.month
root.filename = filedialog.askopenfilenames(initialdir = "Z:\SGI\SYNCBBG",title = "Select your files",filetypes = (("Fichier 1","f6365full_account_refresh*"+str(month)+str(day)+".1"),("Fichier 1","f6365icsh*"+str(month)+str(day)+".1"),("all files",".*")))
root.withdraw()
return (root.filename)
What I want is just to have a function that automatically retrieves all files of a type (that I specify) in two different directories. I did this, and the code runs and prints the result, but after that Python stops responding and there is a bug, so I have to close Python. Another thing is that I'm getting the name of the file, not the absolute path, but it's not the main problem:
def path_L2():
os.chdir("Z:/SGI/SYNCBBG/L2/results/results")
for file in glob.glob("f6365full_account_refresh*"+str(month)+str(day)+".1"):
return file
for file in glob.glob("f6365icsh*"+str(month)+str(day)+".1"):
return file
def path_L3():
os.chdir("Z:/SGI/SYNCBBG/L3/results/results")
for file in glob.glob("f6365full_account_refresh*"+str(month)+str(day)+".1"):
return file
for file in glob.glob("f6365icsh*"+str(month)+str(day)+".1"):
return file
paths=path_L2()
print(paths)