Skip to content

Instantly share code, notes, and snippets.

@izmcm
Created August 30, 2021 21:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save izmcm/6a5d6fa8d4ec65fd9851a1c06c8946ac to your computer and use it in GitHub Desktop.
Save izmcm/6a5d6fa8d4ec65fd9851a1c06c8946ac to your computer and use it in GitHub Desktop.
Lists all files of a given extension in a given folder recursively
import magic
import glob
from os.path import isfile
ROOT_DIR = 'backup'
WANTED_EXTENSION = 'sqlite'
for filename in glob.iglob(ROOT_DIR + '/**', recursive=True):
if isfile(filename):
extension = magic.from_file(filename, mime = True)
if WANTED_EXTENSION in extension:
print(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment