Created
November 11, 2025 19:27
-
-
Save esauOp/b16b7f52f89a1507c53209b5762431e6 to your computer and use it in GitHub Desktop.
Revisions
-
esauOp created this gist
Nov 11, 2025 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ #!/usr/bin/env python3 from pathlib import Path import shutil DOWNLOADS = Path.home() / "Downloads" BUCKETS = { "Documents": {".pdf", ".docx", ".doc", ".txt", ".md", ".odt", ".rtf"}, "Images": {".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".heic"}, "Audio": {".mp3", ".wav", ".flac", ".m4a", ".ogg"}, "Video": {".mp4", ".mkv", ".mov", ".avi", ".webm"}, "Archives": {".zip", ".tar", ".gz", ".bz2", ".7z", ".xz"}, "Code": {".py", ".js", ".ts", ".sh", ".rb", ".go", ".c", ".cpp", ".java"}, "Spreadsheets": {".csv", ".xlsx", ".xls", ".ods"}, "Installers": {".deb", ".rpm", ".msi", ".exe", ".dmg", ".pkg", ".apk"}, "Other": set(), } def bucket_for(path: Path) -> Path: ext = path.suffix.lower() for folder, exts in BUCKETS.items(): if ext in exts: return DOWNLOADS / folder return DOWNLOADS / "Other" def main(): for item in DOWNLOADS.iterdir(): if item.is_file(): target_dir = bucket_for(item) target_dir.mkdir(exist_ok=True) try: shutil.move(str(item), str(target_dir / item.name)) except Exception: # Skip files that cannot be moved continue if __name__ == "__main__": main()