Last active
February 3, 2026 15:21
-
-
Save uncogeek/08de086f2adf9977ea52bed21ca44ca2 to your computer and use it in GitHub Desktop.
searcher.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| root_dir = r"C:\dev\" # change this where to search | |
| needle = "Your-String" # what you search for | |
| for dirpath, dirnames, filenames in os.walk(root_dir): | |
| for filename in filenames: | |
| if filename.lower().endswith(".php"): | |
| full_path = os.path.join(dirpath, filename) | |
| try: | |
| with open(full_path, "r", encoding="utf-8", errors="ignore") as f: | |
| for lineno, line in enumerate(f, start=1): | |
| if needle in line: | |
| print(f"{full_path}:{lineno}: {line.strip()}") | |
| except Exception as e: | |
| print(f"Could not read {full_path}: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment