(Dec-22-2019, 12:06 AM)lastyle Wrote: lets assume there is a directory that matches my searchpattern, how do i reflect that ?In the last code with
os.walk()
it only search for files
(in all sub-folders).So if a folder it's named
folderbestfile
it will not be in result,but files with
bestfile
names in this folder will be in result as wanted.If need in a other cases to check if something is a file or folder can use.
os.path.isfile(path) os.path.isdir(path)Or if using pathlib.
my_file.is_file() my_file.is_dir()