tidy-folder 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # Tidy Folder ๐Ÿงน
2
+
3
+ A simple command-line tool that organizes messy folders automatically.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g tidy-folder
9
+
10
+ Usage
11
+ tidy-folder <folder>
12
+
13
+ Example:
14
+
15
+ tidy-folder ~/Downloads
16
+
17
+ Dry Run
18
+ Preview changes without moving files:
19
+
20
+ tidy-folder ~/Downloads --dry-run
package/index.js ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ const args = process.argv.slice(2);
7
+
8
+ const dryRun = args.includes("--dry-run");
9
+ const folder = args.find(arg => !arg.startsWith("--"));
10
+
11
+
12
+ if (!folder) {
13
+ console.log("Usage: tidy-folder <folder>");
14
+ console.log("Example: tidy-folder ~/Downloads");
15
+ process.exit(1);
16
+ }
17
+
18
+ const folderPath = path.resolve(folder);
19
+
20
+ if (!fs.existsSync(folderPath)) {
21
+ console.error(`โŒ Folder does not exist: ${folderPath}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ if (!fs.statSync(folderPath).isDirectory()) {
26
+ console.error(`โŒ This is not a folder: ${folderPath}`);
27
+ process.exit(1);
28
+ }
29
+
30
+ const categories = {
31
+ Images: [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"],
32
+ Documents: [".pdf", ".doc", ".docx", ".txt", ".xls", ".xlsx", ".ppt", ".pptx"],
33
+ Videos: [".mp4", ".mkv", ".avi", ".mov", ".webm"],
34
+ Music: [".mp3", ".wav", ".flac", ".aac", ".ogg"],
35
+ Archives: [".zip", ".rar", ".7z", ".tar", ".gz"]
36
+ };
37
+
38
+ const files = fs.readdirSync(folderPath);
39
+
40
+ for (const file of files) {
41
+ const sourcePath = path.join(folderPath, file);
42
+
43
+ if (!fs.statSync(sourcePath).isFile()) {
44
+ continue;
45
+ }
46
+
47
+ const extension = path.extname(file).toLowerCase();
48
+
49
+ let category = "Others";
50
+
51
+ for (const [name, extensions] of Object.entries(categories)) {
52
+ if (extensions.includes(extension)) {
53
+ category = name;
54
+ break;
55
+ }
56
+ }
57
+
58
+ const destinationFolder = path.join(folderPath, category);
59
+ const destinationPath = path.join(destinationFolder, file);
60
+
61
+ if (!fs.existsSync(destinationFolder)) {
62
+ fs.mkdirSync(destinationFolder);
63
+ }
64
+
65
+ if (dryRun) {
66
+ console.log(`โ†’ ${file} โ†’ ${category}/`);
67
+ } else {
68
+ fs.renameSync(sourcePath, destinationPath);
69
+ console.log(`โœ“ ${file} โ†’ ${category}/`);
70
+ }
71
+
72
+ }
73
+
74
+ if (dryRun) {
75
+ console.log("\n๐Ÿ‘€ Dry run complete. No files were moved.");
76
+ } else {
77
+ console.log("\n๐ŸŽ‰ Folder organized!");
78
+ }
79
+
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "tidy-folder",
3
+ "version": "1.0.0",
4
+ "description": "Organize messy folders automatically from your terminal",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "tidy-folder": "index.js"
8
+ },
9
+ "scripts": {
10
+ "start": "node index.js"
11
+ },
12
+ "keywords": [
13
+ "file-organizer",
14
+ "folder-organizer",
15
+ "cli",
16
+ "productivity"
17
+ ],
18
+ "author": "YOGESH YADAV",
19
+ "license": "MIT"
20
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
Binary file