Linux file path regex
Witt construction reviews
Find is capable to perform several actions on the files or directories that are found with options -exec and -execdir (the latter is "GNU find only" feature). At the same time it is a perfect tool to destroy your filesystem as option -exec blindly and very quickly executes commands you specified for the set of files provided by find.
import os import re regex = re.compile('(.*zip$)|(.*rar$)|(.*r01$)') rx = '(.*zip$)|(.*rar$)|(.*r01$)' for root, dirs, files in os.walk("../Documents"): for file in files: res = re.match(rx, file) if res: if res.group(1): print("ZIP",file) if res.group(2): print("RAR",file) if res.group(3): print("R01",file)