Created
August 30, 2021 21:24
-
-
Save izmcm/6a5d6fa8d4ec65fd9851a1c06c8946ac to your computer and use it in GitHub Desktop.
Lists all files of a given extension in a given folder recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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