Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions public/data/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@
],
"tags": ["python", "file", "write", "utility"],
"author": "technoph1le"
},
{
"title": "Find Files",
"description": "Finds all files of the specified type within a given directory.",
"code": [
"import os",
"",
"def find_files(directory, file_type):",
" file_type = file_type.lower() # Convert file_type to lowercase",
" found_files = []",
"",
" for root, _, files in os.walk(directory):",
" for file in files:",
" file_ext = os.path.splitext(file)[1].lower()",
" if file_ext == file_type:",
" full_path = os.path.join(root, file)",
" found_files.append(full_path)",
"",
" return found_files",
"",
"# Example Usage:",
"pdf_files = find_files('/path/to/your/directory', '.pdf')",
"print(pdf_files)"
],
"tags": ["python", "os", "filesystem", "file_search"],
"author": "Jackeastern"
}
]
},
Expand Down