Python Forum
Python: Ignore\Exclude files that contain words
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python: Ignore\Exclude files that contain words
#1
maybe someone needs this information

def save_to_pdf(directory_path):
    modified_files = []
    file_count = 0
    for root, dirs, files in os.walk(directory_path):
        for file_name in files:
            if file_name.endswith(".html"):

                # ignore files that contain 'webinar' in their name
                if "webinar" in file_name:
                    print(f"Fișierul {file_name} conține 'webinar' în numele său și va fi ignorat.")
                    continue

                file_path = root + os.sep + file_name
                file_content = read_text_from_file(file_path)

                # ignore files that contain 'https://pastebin.com' in their content
                if "https://pastebin.com" in file_content:
                    print(f"Fișierul {file_name} conține 'https://pastebin.com' în conținutul său și va fi ignorat.")
                    continue
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020