Python Forum

Full Version: Python: Ignore\Exclude files that contain words
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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