Skip to content

Instantly share code, notes, and snippets.

@me-suzy
Last active July 28, 2023 16:42
Show Gist options
  • Save me-suzy/644cff57c5691cf6d336ba56c57b0450 to your computer and use it in GitHub Desktop.
Save me-suzy/644cff57c5691cf6d336ba56c57b0450 to your computer and use it in GitHub Desktop.
Python: Ignore\Exclude files that contain words
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"):
# ignora fisierele care contin 'webinar' in numele lor
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)
# ignora fisierele care contin 'https://pastebin.com' in continutul lor
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment