0

I'm trying to create a filedialog that enables the user to navigate to a folder and type in a filename with wildcard characters. The returned filepath / string is used to filter the files to be processed by the BatchProcess operation.

I want something that would look a bit like this where the returned filefilter would be "C:/Users/Mike/Documents/fileexample*.txt where * is a wild card character. It seems tkinter filedialogs it won't allow you to enter *. Is there someway to turn off the filename validation?

import tkinter as tk

filefilter = tk.filedialog.asksaveasfilename()

for filename in BatchProcess(filefilter):
    print(filename)
Mike Smith
  • 41
  • 5
  • I don't think there is any way of doing that. You can specify `multiple=True` inside the `asksaveasfilename()`, if you want the user to be able to select multiple files. – TheLizzard Sep 06 '21 at 21:17
  • Tkinter has no built-in ability for this. Perhaps use `.askdirectory()` to get the folder, and have an ordinary Entry for the filter pattern. – jasonharper Sep 06 '21 at 21:18
  • You might try `os.walk` that will recursively extract path files – Derek Sep 07 '21 at 07:44

0 Answers0