Skip to content

Instantly share code, notes, and snippets.

@gmotzespina
Created July 2, 2024 16:40
Show Gist options
  • Select an option

  • Save gmotzespina/2b9a17070b0b11201422d33f50956ec6 to your computer and use it in GitHub Desktop.

Select an option

Save gmotzespina/2b9a17070b0b11201422d33f50956ec6 to your computer and use it in GitHub Desktop.
File System Example
import os
def find_files(directory, pattern):
for item in os.listdir(directory):
full_path = os.path.join(directory, item)
if os.path.isfile(full_path) and pattern in item:
print(full_path)
elif os.path.isdir(full_path):
find_files(full_path, pattern) # Recurse into subdirectory
find_files('/path/to/your/directory', '.txt') # Find all .txt files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment