Skip to content

Instantly share code, notes, and snippets.

@pointofpresence
Created April 10, 2022 14:03
Show Gist options
  • Save pointofpresence/92b18c19652ce66805d41de9b1ecf302 to your computer and use it in GitHub Desktop.
Save pointofpresence/92b18c19652ce66805d41de9b1ecf302 to your computer and use it in GitHub Desktop.
def cool_glob(dir_list, patterns_list, recursive=False):
output = []
template = '**/{pattern}' if recursive else '{pattern}'
for dir_name in list(set(dir_list)):
for pattern in list(set(patterns_list)):
output.extend(list(pathlib.Path(dir_name).glob(template.format(pattern=pattern))))
return output
res = cool_glob(
[r'K:\_SYNTHWAVE\music\cover', r'K:\_CLIPARTS\Космос'],
['*.png', '*.jpg', '*.gif', '*.jpeg'],
True
)
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment