downsweep 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
downsweep/__init__.py ADDED
File without changes
downsweep/cli.py ADDED
@@ -0,0 +1,83 @@
1
+ import argparse
2
+ import shutil
3
+ from pathlib import Path
4
+
5
+ CATEGORIES = {
6
+ "Images": [".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".svg", ".avif", ".jfif"],
7
+ "Videos": [".mp4", ".mkv", ".avi", ".mov", ".webm"],
8
+ "Audio": [".mp3", ".wav", ".flac", ".m4a"],
9
+ "PDFs": [".pdf"],
10
+ "Documents": [".doc", ".docx", ".txt", ".ppt", ".pptx", ".xls", ".xlsx", ".csv"],
11
+ "Archives": [".zip", ".rar", ".7z", ".tar", ".gz"],
12
+ "Programs": [".exe", ".msi"],
13
+ "Code": [".py", ".js", ".html", ".htm", ".css", ".java", ".cpp", ".ipynb"],
14
+ }
15
+
16
+ # Files still being downloaded - never touch these
17
+ SKIP = {".crdownload", ".part", ".tmp", ".ini", ".lnk"}
18
+
19
+
20
+ def get_category(file):
21
+ ext = file.suffix.lower()
22
+ for name, extensions in CATEGORIES.items():
23
+ if ext in extensions:
24
+ return name
25
+ return "Other"
26
+
27
+
28
+ def unique_path(path):
29
+ # If a file with the same name exists, add (1), (2)... instead of overwriting
30
+ if not path.exists():
31
+ return path
32
+ counter = 1
33
+ while True:
34
+ new_path = path.with_name(f"{path.stem} ({counter}){path.suffix}")
35
+ if not new_path.exists():
36
+ return new_path
37
+ counter += 1
38
+
39
+
40
+ def main():
41
+ parser = argparse.ArgumentParser(
42
+ description="Sort a messy folder into neat sub-folders by file type."
43
+ )
44
+ parser.add_argument(
45
+ "folder",
46
+ nargs="?",
47
+ default=str(Path.home() / "Downloads"),
48
+ help="Folder to clean (default: your Downloads folder)",
49
+ )
50
+ parser.add_argument(
51
+ "--preview",
52
+ action="store_true",
53
+ help="Show what would move, without moving anything",
54
+ )
55
+ args = parser.parse_args()
56
+
57
+ folder = Path(args.folder)
58
+ if not folder.is_dir():
59
+ print(f"Folder not found: {folder}")
60
+ return
61
+
62
+ count = 0
63
+ for item in folder.iterdir():
64
+ if not item.is_file() or item.suffix.lower() in SKIP:
65
+ continue
66
+ category = get_category(item)
67
+ if args.preview:
68
+ print(f"Would move: {item.name} -> {category}")
69
+ else:
70
+ target_dir = folder / category
71
+ target_dir.mkdir(exist_ok=True)
72
+ shutil.move(str(item), str(unique_path(target_dir / item.name)))
73
+ print(f"Moved: {item.name} -> {category}")
74
+ count += 1
75
+
76
+ if args.preview:
77
+ print(f"\n{count} file(s) would be moved. Nothing was changed.")
78
+ else:
79
+ print(f"\nDone! {count} file(s) sorted.")
80
+
81
+
82
+ if __name__ == "__main__":
83
+ main()
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.4
2
+ Name: downsweep
3
+ Version: 0.1.0
4
+ Summary: Sort a messy Downloads folder into neat folders with one command.
5
+ Author: Hari Prasath S
6
+ Keywords: downloads,organizer,cleaner,files,cli
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+
10
+ # downsweep
11
+
12
+ Sort a messy Downloads folder into neat folders with one command.
13
+
14
+ ## Install
15
+
16
+ pip install downsweep
17
+
18
+ ## Use
19
+
20
+ Clean your Downloads folder:
21
+
22
+ downsweep
23
+
24
+ See what would move first, without changing anything:
25
+
26
+ downsweep --preview
27
+
28
+ Clean any other folder:
29
+
30
+ downsweep "C:\path\to\folder"
31
+
32
+ ## What it does
33
+
34
+ Files are moved into folders like Images, Videos, Audio, PDFs, Documents,
35
+ Archives, Programs, Code and Other. Files still being downloaded are skipped,
36
+ and existing files are never overwritten.
@@ -0,0 +1,7 @@
1
+ downsweep/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ downsweep/cli.py,sha256=la_wgflbxIoEkg4OgiR_u3Rgzoq2Sh88RRqv8mqxnG8,2574
3
+ downsweep-0.1.0.dist-info/METADATA,sha256=b0klKceY1MMfor9Ev6DVEZ_8iZaB82erZ6dXVeCW9wM,822
4
+ downsweep-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ downsweep-0.1.0.dist-info/entry_points.txt,sha256=1e4DaXkZkbyy7yPBehfaVbmQycci7vohekKZVkbAg7o,49
6
+ downsweep-0.1.0.dist-info/top_level.txt,sha256=iGkb1dewIQsT2toORVatPUfAzFSQCa7NQ2_YFiofBa0,10
7
+ downsweep-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ downsweep = downsweep.cli:main
@@ -0,0 +1 @@
1
+ downsweep