i write folder content (files wit .pdf .doc and .xls) in a small txt file. every filename get a new line in the txt file. Works fine. Now i want to remove all line with the .pdf files. I still use the following code to remove false entries (fail.png in this case):
def clean():
with open("files.txt", "r") as f:
lines = f.readlines()
with open("files.txt", "w") as f:
for line in lines:
if line.strip("\n") != "fail.png":
f.write(line)
clean_folderlog()
Is it possible to use some sort of "wildcard" (*.pdf) instead of the specific file name? Or is there a complete other way to solve that?
Thanks a lot