I am using OS to walk through a very large number of files. Due to performance reasons I am only interested in the files which do not end in "_TT.docx"," TT.docx", "-TT.docx", " tt.docx", "_tt.docx" or ".pdf"
I only want the docx files without any of the TT combination or the pdfs.
I tried the code below to eliminate several parameters at the same time but it does not work (identation error). I don't find it. Where do I go wrong?
files_in_dir = []
others_in_dir = []
targets_in_dir = []
# r=>root, d=>directories, f=>files
for r, d, f in os.walk(location):
for item in f:
if '.pdf' in item:
pdfs_in_dir.append(os.path.join(r, item))
elif 'SS' in item:
others_in_dir.append(os.path.join(r, item))
elif '.docx' in item:
targets_in_dir.append(os.path.join(r, item))