sfo-file-organizer 1.0.0__tar.gz
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.
- sfo_file_organizer-1.0.0/PKG-INFO +290 -0
- sfo_file_organizer-1.0.0/README.md +257 -0
- sfo_file_organizer-1.0.0/app_config.py +94 -0
- sfo_file_organizer-1.0.0/gui.py +1374 -0
- sfo_file_organizer-1.0.0/history.py +242 -0
- sfo_file_organizer-1.0.0/logging_config.py +81 -0
- sfo_file_organizer-1.0.0/organizer.py +643 -0
- sfo_file_organizer-1.0.0/pyproject.toml +62 -0
- sfo_file_organizer-1.0.0/rules.py +230 -0
- sfo_file_organizer-1.0.0/scheduler.py +75 -0
- sfo_file_organizer-1.0.0/setup.cfg +4 -0
- sfo_file_organizer-1.0.0/sfo_file_organizer.egg-info/PKG-INFO +290 -0
- sfo_file_organizer-1.0.0/sfo_file_organizer.egg-info/SOURCES.txt +19 -0
- sfo_file_organizer-1.0.0/sfo_file_organizer.egg-info/dependency_links.txt +1 -0
- sfo_file_organizer-1.0.0/sfo_file_organizer.egg-info/entry_points.txt +7 -0
- sfo_file_organizer-1.0.0/sfo_file_organizer.egg-info/requires.txt +5 -0
- sfo_file_organizer-1.0.0/sfo_file_organizer.egg-info/top_level.txt +7 -0
- sfo_file_organizer-1.0.0/tests/test_fixes.py +30 -0
- sfo_file_organizer-1.0.0/tests/test_organizer.py +294 -0
- sfo_file_organizer-1.0.0/tests/test_rules.py +109 -0
- sfo_file_organizer-1.0.0/tests/test_smart_context.py +68 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sfo-file-organizer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Python utility that automatically organizes files into categorized folders based on file types, with rule-based classification and real-time monitoring.
|
|
5
|
+
Author: pjames-tech
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pjames-tech/sfo-file-organizer
|
|
8
|
+
Project-URL: Repository, https://github.com/pjames-tech/sfo-file-organizer
|
|
9
|
+
Project-URL: Issues, https://github.com/pjames-tech/sfo-file-organizer/issues
|
|
10
|
+
Keywords: file-organizer,automation,file-management,desktop-app
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Environment :: MacOS X
|
|
14
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Desktop Environment :: File Managers
|
|
25
|
+
Classifier: Topic :: System :: Filesystems
|
|
26
|
+
Classifier: Topic :: Utilities
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
Requires-Dist: watchdog>=3.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pyinstaller>=6.0.0; extra == "dev"
|
|
33
|
+
|
|
34
|
+
# SFO File Organizer
|
|
35
|
+
|
|
36
|
+
A Python utility that automatically organizes files into categorized folders based on their file types, with support for rule-based classification, structured logging, and real-time monitoring.
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- ๐ **Smart Classification**
|
|
41
|
+
- **Rule-based classification** (keywords take priority)
|
|
42
|
+
- **Extension-based fallback** classification (supports PHP, TS, JSX, etc.)
|
|
43
|
+
- โ๏ธ **Customizable Categories** - Easy to add custom file categories and rules
|
|
44
|
+
- ๐ **Duplicate Handling** - Automatic renaming for duplicate filenames
|
|
45
|
+
- ๐ **Statistics** - Summary report after organization
|
|
46
|
+
- ๐งช **Dry-Run Mode** - Preview changes without moving files
|
|
47
|
+
- ๐ **Structured Logging** - Console and file logging with configurable levels
|
|
48
|
+
- ๐ฅ๏ธ **Modern Desktop UI** - Sleek dark-themed interface with:
|
|
49
|
+
- **Scheduling**: Automate organization to run daily.
|
|
50
|
+
- **Flatten Directory**: Undo organization by moving files back to the root (only targets organizer-created folders).
|
|
51
|
+
- **Watch Mode**: Real-time folder monitoring.
|
|
52
|
+
- โฉ๏ธ **Undo Support** - Easily revert any organization session (auto-cleans empty folders)
|
|
53
|
+
- ๐ง **Smart Context** - Auto-detects folder purpose by name (Photos, Documents, etc.) for specialized sorting
|
|
54
|
+
|
|
55
|
+
## Platform Compatibility
|
|
56
|
+
|
|
57
|
+
| Platform | Pre-built Executable | Run from Source |
|
|
58
|
+
| ----------- | -------------------------------- | --------------- |
|
|
59
|
+
| **Windows** | โ
`.exe` available | โ
Supported |
|
|
60
|
+
| **macOS** | โ
Available via GitHub Releases | โ
Supported |
|
|
61
|
+
| **Linux** | โ
Available via GitHub Releases | โ
Supported |
|
|
62
|
+
|
|
63
|
+
> **Note:** Pre-built executables for all platforms are automatically generated via GitHub Actions and attached to each [Release](https://github.com/pjames-tech/sfo-file-organizer/releases).
|
|
64
|
+
|
|
65
|
+
### macOS / Linux Setup
|
|
66
|
+
|
|
67
|
+
1. **Install Python 3.8+** (usually pre-installed on Linux, download from [python.org](https://python.org) for macOS)
|
|
68
|
+
|
|
69
|
+
2. **Clone and install dependencies:**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git clone https://github.com/pjames-tech/sfo-file-organizer.git
|
|
73
|
+
cd sfo-file-organizer
|
|
74
|
+
pip install -r requirements.txt
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
3. **Run the GUI:**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python gui.py
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
4. **Or run the CLI:**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
python organizer.py --source ~/Downloads
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Building Your Own Executable (Optional)
|
|
90
|
+
|
|
91
|
+
If you want to create a native executable for your platform:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Install PyInstaller
|
|
95
|
+
pip install pyinstaller
|
|
96
|
+
|
|
97
|
+
# Build the executable
|
|
98
|
+
pyinstaller --onefile --windowed gui.py
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The executable will be created in the `dist/` folder.
|
|
102
|
+
|
|
103
|
+
## Architecture
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
sfo-file-organizer/
|
|
107
|
+
โโโ organizer.py # Main CLI and orchestration
|
|
108
|
+
โโโ gui.py # Desktop GUI application (tkinter)
|
|
109
|
+
โโโ app_config.py # Configuration and file categories
|
|
110
|
+
โโโ rules.py # Rule-based classification engine
|
|
111
|
+
โโโ scheduler.py # Windows Task Scheduler integration
|
|
112
|
+
โโโ history.py # Undo/redo history management
|
|
113
|
+
โโโ logging_config.py # Logging configuration
|
|
114
|
+
โโโ run_organizer.bat # Batch script helper
|
|
115
|
+
โโโ requirements.txt # Dependencies
|
|
116
|
+
โโโ tests/ # Unit tests
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Classification Priority
|
|
120
|
+
|
|
121
|
+
1. **Keyword Rules** - Custom rules take priority.
|
|
122
|
+
2. **File Extension** - Standard classification based on file type.
|
|
123
|
+
|
|
124
|
+
## Installation
|
|
125
|
+
|
|
126
|
+
### Option 1: Install via pip (Recommended for all platforms)
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pip install sfo-file-organizer
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Then run:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
sfo-file-organizer # Launch GUI
|
|
136
|
+
sfo # Shortcut for GUI
|
|
137
|
+
sfo-cli --source ~/Downloads # CLI mode
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Option 2: Download Pre-built Executable
|
|
141
|
+
|
|
142
|
+
| Platform | Download |
|
|
143
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
144
|
+
| **Windows** | [SFO-File-Organizer-Windows.exe](https://github.com/pjames-tech/sfo-file-organizer/releases/latest/download/SFO-File-Organizer-Windows.exe) |
|
|
145
|
+
| **macOS** | [SFO-File-Organizer-macOS.zip](https://github.com/pjames-tech/sfo-file-organizer/releases/latest/download/SFO-File-Organizer-macOS.zip) |
|
|
146
|
+
| **Linux** | [SFO-File-Organizer-Linux](https://github.com/pjames-tech/sfo-file-organizer/releases/latest/download/SFO-File-Organizer-Linux) |
|
|
147
|
+
|
|
148
|
+
### Option 3: Run from Source
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
git clone https://github.com/pjames-tech/sfo-file-organizer.git
|
|
152
|
+
cd sfo-file-organizer
|
|
153
|
+
pip install -r requirements.txt
|
|
154
|
+
python gui.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Usage
|
|
158
|
+
|
|
159
|
+
### Quick Start
|
|
160
|
+
|
|
161
|
+
1. **Install** using one of the methods above.
|
|
162
|
+
2. **Launch** the application (GUI or CLI).
|
|
163
|
+
3. **Select** the folder you want to organize.
|
|
164
|
+
4. **Click "Organize Now"** and watch your files get sorted!
|
|
165
|
+
|
|
166
|
+
## ๐๏ธ Watch Mode
|
|
167
|
+
|
|
168
|
+
Watch Mode monitors your source folder in real-time. Any file you drop into the folder will be automatically categorized and moved instantly.
|
|
169
|
+
|
|
170
|
+
- **GUI**: Just toggle the **"Watch Mode"** switch.
|
|
171
|
+
- **CLI**: Run `python organizer.py --watch`
|
|
172
|
+
|
|
173
|
+
### Desktop GUI
|
|
174
|
+
|
|
175
|
+
Launch the graphical interface:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python gui.py
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Features:**
|
|
182
|
+
|
|
183
|
+
- ๐ Browse and select any folder to organize
|
|
184
|
+
- ๐ **Organize Now** - One-click file organization
|
|
185
|
+
- ๐๏ธ **Preview Changes** - See what will happen before committing
|
|
186
|
+
- ๐งน **Flatten** - Move files out of organizer-created subfolders back to the root (preserves pre-existing folders)
|
|
187
|
+
- โฐ **Automation** - Schedule daily organization tasks
|
|
188
|
+
- โฉ๏ธ **Undo Last** - Restore files to their original locations and clean up empty folders
|
|
189
|
+
- ๐ Activity log with colored output
|
|
190
|
+
- ๐ง **Smart Context** - Enable to sort images by year or documents by type based on folder name
|
|
191
|
+
- โ **Watch Mode** - Real-time folder monitoring
|
|
192
|
+
|
|
193
|
+
### CLI Mode
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Organize Downloads folder (in-place)
|
|
197
|
+
python organizer.py --source ~/Downloads
|
|
198
|
+
|
|
199
|
+
# Dry-run (preview without moving files)
|
|
200
|
+
python organizer.py --dry-run --source ~/Downloads
|
|
201
|
+
|
|
202
|
+
# Undo last organization
|
|
203
|
+
python organizer.py --undo
|
|
204
|
+
|
|
205
|
+
# View history
|
|
206
|
+
python organizer.py --history
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### CLI Options
|
|
210
|
+
|
|
211
|
+
| Flag | Short | Description |
|
|
212
|
+
| --------------- | ----- | ----------------------------------------------- |
|
|
213
|
+
| `--source` | `-s` | Source directory to organize |
|
|
214
|
+
| `--dest` | `-d` | Destination directory (default: same as source) |
|
|
215
|
+
| `--dry-run` | `-n` | Preview changes without moving files |
|
|
216
|
+
| `--in-place` | `-i` | Organize within source folder (default) |
|
|
217
|
+
| `--watch` | `-w` | Monitor folder and organize in real-time |
|
|
218
|
+
| `--undo` | | Undo the last organization |
|
|
219
|
+
| `--history` | | Show organization history |
|
|
220
|
+
| `--log-level` | `-l` | Set logging level (DEBUG, INFO, WARNING, ERROR) |
|
|
221
|
+
| `--no-log-file` | | Disable logging to file |
|
|
222
|
+
|
|
223
|
+
### Examples
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Preview what would happen
|
|
227
|
+
python organizer.py --dry-run --source ./messy_folder
|
|
228
|
+
|
|
229
|
+
# Quick organize current downloads
|
|
230
|
+
python organizer.py --source ~/Downloads
|
|
231
|
+
|
|
232
|
+
# Start watching a folder
|
|
233
|
+
python organizer.py --watch --source ~/Downloads
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Configuration
|
|
237
|
+
|
|
238
|
+
### File Categories (`app_config.py`)
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
FILE_CATEGORIES = {
|
|
242
|
+
"Images": [".jpg", ".jpeg", ".png", ".gif", ...],
|
|
243
|
+
"Documents": [".pdf", ".doc", ".docx", ".txt", ...],
|
|
244
|
+
"Videos": [".mp4", ".mkv", ".avi", ...],
|
|
245
|
+
"Code": [".py", ".js", ".php", ".ts", ".jsx", ...],
|
|
246
|
+
# Add custom categories here
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Keyword Rules (`rules.py`)
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
KEYWORD_RULES = {
|
|
254
|
+
"invoice": "Documents", # Files with "invoice" go to Documents
|
|
255
|
+
"screenshot": "Images", # Files with "screenshot" go to Images
|
|
256
|
+
# Add custom rules here
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Testing
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Install pytest
|
|
264
|
+
pip install pytest
|
|
265
|
+
|
|
266
|
+
# Run all tests
|
|
267
|
+
pytest tests/ -v
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Automatic Scheduling (Windows Task Scheduler)
|
|
271
|
+
|
|
272
|
+
Run the organizer automatically on a schedule using the included batch script.
|
|
273
|
+
|
|
274
|
+
### Quick Setup
|
|
275
|
+
|
|
276
|
+
1. **Edit `run_organizer.bat`** to customize your source/destination folders:
|
|
277
|
+
|
|
278
|
+
```batch
|
|
279
|
+
"C:\Python314\python.exe" organizer.py --source "%USERPROFILE%\Downloads" --dest "%USERPROFILE%\Downloads" --log-level INFO
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
2. **Create the scheduled task** (run in PowerShell as admin):
|
|
283
|
+
|
|
284
|
+
```powershell
|
|
285
|
+
schtasks /create /tn "Smart File Organizer" /tr "C:\path\to\run_organizer.bat" /sc daily /st 12:00 /f
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
MIT License
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# SFO File Organizer
|
|
2
|
+
|
|
3
|
+
A Python utility that automatically organizes files into categorized folders based on their file types, with support for rule-based classification, structured logging, and real-time monitoring.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ๐ **Smart Classification**
|
|
8
|
+
- **Rule-based classification** (keywords take priority)
|
|
9
|
+
- **Extension-based fallback** classification (supports PHP, TS, JSX, etc.)
|
|
10
|
+
- โ๏ธ **Customizable Categories** - Easy to add custom file categories and rules
|
|
11
|
+
- ๐ **Duplicate Handling** - Automatic renaming for duplicate filenames
|
|
12
|
+
- ๐ **Statistics** - Summary report after organization
|
|
13
|
+
- ๐งช **Dry-Run Mode** - Preview changes without moving files
|
|
14
|
+
- ๐ **Structured Logging** - Console and file logging with configurable levels
|
|
15
|
+
- ๐ฅ๏ธ **Modern Desktop UI** - Sleek dark-themed interface with:
|
|
16
|
+
- **Scheduling**: Automate organization to run daily.
|
|
17
|
+
- **Flatten Directory**: Undo organization by moving files back to the root (only targets organizer-created folders).
|
|
18
|
+
- **Watch Mode**: Real-time folder monitoring.
|
|
19
|
+
- โฉ๏ธ **Undo Support** - Easily revert any organization session (auto-cleans empty folders)
|
|
20
|
+
- ๐ง **Smart Context** - Auto-detects folder purpose by name (Photos, Documents, etc.) for specialized sorting
|
|
21
|
+
|
|
22
|
+
## Platform Compatibility
|
|
23
|
+
|
|
24
|
+
| Platform | Pre-built Executable | Run from Source |
|
|
25
|
+
| ----------- | -------------------------------- | --------------- |
|
|
26
|
+
| **Windows** | โ
`.exe` available | โ
Supported |
|
|
27
|
+
| **macOS** | โ
Available via GitHub Releases | โ
Supported |
|
|
28
|
+
| **Linux** | โ
Available via GitHub Releases | โ
Supported |
|
|
29
|
+
|
|
30
|
+
> **Note:** Pre-built executables for all platforms are automatically generated via GitHub Actions and attached to each [Release](https://github.com/pjames-tech/sfo-file-organizer/releases).
|
|
31
|
+
|
|
32
|
+
### macOS / Linux Setup
|
|
33
|
+
|
|
34
|
+
1. **Install Python 3.8+** (usually pre-installed on Linux, download from [python.org](https://python.org) for macOS)
|
|
35
|
+
|
|
36
|
+
2. **Clone and install dependencies:**
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/pjames-tech/sfo-file-organizer.git
|
|
40
|
+
cd sfo-file-organizer
|
|
41
|
+
pip install -r requirements.txt
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
3. **Run the GUI:**
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python gui.py
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
4. **Or run the CLI:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
python organizer.py --source ~/Downloads
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Building Your Own Executable (Optional)
|
|
57
|
+
|
|
58
|
+
If you want to create a native executable for your platform:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Install PyInstaller
|
|
62
|
+
pip install pyinstaller
|
|
63
|
+
|
|
64
|
+
# Build the executable
|
|
65
|
+
pyinstaller --onefile --windowed gui.py
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The executable will be created in the `dist/` folder.
|
|
69
|
+
|
|
70
|
+
## Architecture
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
sfo-file-organizer/
|
|
74
|
+
โโโ organizer.py # Main CLI and orchestration
|
|
75
|
+
โโโ gui.py # Desktop GUI application (tkinter)
|
|
76
|
+
โโโ app_config.py # Configuration and file categories
|
|
77
|
+
โโโ rules.py # Rule-based classification engine
|
|
78
|
+
โโโ scheduler.py # Windows Task Scheduler integration
|
|
79
|
+
โโโ history.py # Undo/redo history management
|
|
80
|
+
โโโ logging_config.py # Logging configuration
|
|
81
|
+
โโโ run_organizer.bat # Batch script helper
|
|
82
|
+
โโโ requirements.txt # Dependencies
|
|
83
|
+
โโโ tests/ # Unit tests
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Classification Priority
|
|
87
|
+
|
|
88
|
+
1. **Keyword Rules** - Custom rules take priority.
|
|
89
|
+
2. **File Extension** - Standard classification based on file type.
|
|
90
|
+
|
|
91
|
+
## Installation
|
|
92
|
+
|
|
93
|
+
### Option 1: Install via pip (Recommended for all platforms)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install sfo-file-organizer
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Then run:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
sfo-file-organizer # Launch GUI
|
|
103
|
+
sfo # Shortcut for GUI
|
|
104
|
+
sfo-cli --source ~/Downloads # CLI mode
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Option 2: Download Pre-built Executable
|
|
108
|
+
|
|
109
|
+
| Platform | Download |
|
|
110
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| **Windows** | [SFO-File-Organizer-Windows.exe](https://github.com/pjames-tech/sfo-file-organizer/releases/latest/download/SFO-File-Organizer-Windows.exe) |
|
|
112
|
+
| **macOS** | [SFO-File-Organizer-macOS.zip](https://github.com/pjames-tech/sfo-file-organizer/releases/latest/download/SFO-File-Organizer-macOS.zip) |
|
|
113
|
+
| **Linux** | [SFO-File-Organizer-Linux](https://github.com/pjames-tech/sfo-file-organizer/releases/latest/download/SFO-File-Organizer-Linux) |
|
|
114
|
+
|
|
115
|
+
### Option 3: Run from Source
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
git clone https://github.com/pjames-tech/sfo-file-organizer.git
|
|
119
|
+
cd sfo-file-organizer
|
|
120
|
+
pip install -r requirements.txt
|
|
121
|
+
python gui.py
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Usage
|
|
125
|
+
|
|
126
|
+
### Quick Start
|
|
127
|
+
|
|
128
|
+
1. **Install** using one of the methods above.
|
|
129
|
+
2. **Launch** the application (GUI or CLI).
|
|
130
|
+
3. **Select** the folder you want to organize.
|
|
131
|
+
4. **Click "Organize Now"** and watch your files get sorted!
|
|
132
|
+
|
|
133
|
+
## ๐๏ธ Watch Mode
|
|
134
|
+
|
|
135
|
+
Watch Mode monitors your source folder in real-time. Any file you drop into the folder will be automatically categorized and moved instantly.
|
|
136
|
+
|
|
137
|
+
- **GUI**: Just toggle the **"Watch Mode"** switch.
|
|
138
|
+
- **CLI**: Run `python organizer.py --watch`
|
|
139
|
+
|
|
140
|
+
### Desktop GUI
|
|
141
|
+
|
|
142
|
+
Launch the graphical interface:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python gui.py
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Features:**
|
|
149
|
+
|
|
150
|
+
- ๐ Browse and select any folder to organize
|
|
151
|
+
- ๐ **Organize Now** - One-click file organization
|
|
152
|
+
- ๐๏ธ **Preview Changes** - See what will happen before committing
|
|
153
|
+
- ๐งน **Flatten** - Move files out of organizer-created subfolders back to the root (preserves pre-existing folders)
|
|
154
|
+
- โฐ **Automation** - Schedule daily organization tasks
|
|
155
|
+
- โฉ๏ธ **Undo Last** - Restore files to their original locations and clean up empty folders
|
|
156
|
+
- ๐ Activity log with colored output
|
|
157
|
+
- ๐ง **Smart Context** - Enable to sort images by year or documents by type based on folder name
|
|
158
|
+
- โ **Watch Mode** - Real-time folder monitoring
|
|
159
|
+
|
|
160
|
+
### CLI Mode
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Organize Downloads folder (in-place)
|
|
164
|
+
python organizer.py --source ~/Downloads
|
|
165
|
+
|
|
166
|
+
# Dry-run (preview without moving files)
|
|
167
|
+
python organizer.py --dry-run --source ~/Downloads
|
|
168
|
+
|
|
169
|
+
# Undo last organization
|
|
170
|
+
python organizer.py --undo
|
|
171
|
+
|
|
172
|
+
# View history
|
|
173
|
+
python organizer.py --history
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### CLI Options
|
|
177
|
+
|
|
178
|
+
| Flag | Short | Description |
|
|
179
|
+
| --------------- | ----- | ----------------------------------------------- |
|
|
180
|
+
| `--source` | `-s` | Source directory to organize |
|
|
181
|
+
| `--dest` | `-d` | Destination directory (default: same as source) |
|
|
182
|
+
| `--dry-run` | `-n` | Preview changes without moving files |
|
|
183
|
+
| `--in-place` | `-i` | Organize within source folder (default) |
|
|
184
|
+
| `--watch` | `-w` | Monitor folder and organize in real-time |
|
|
185
|
+
| `--undo` | | Undo the last organization |
|
|
186
|
+
| `--history` | | Show organization history |
|
|
187
|
+
| `--log-level` | `-l` | Set logging level (DEBUG, INFO, WARNING, ERROR) |
|
|
188
|
+
| `--no-log-file` | | Disable logging to file |
|
|
189
|
+
|
|
190
|
+
### Examples
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Preview what would happen
|
|
194
|
+
python organizer.py --dry-run --source ./messy_folder
|
|
195
|
+
|
|
196
|
+
# Quick organize current downloads
|
|
197
|
+
python organizer.py --source ~/Downloads
|
|
198
|
+
|
|
199
|
+
# Start watching a folder
|
|
200
|
+
python organizer.py --watch --source ~/Downloads
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Configuration
|
|
204
|
+
|
|
205
|
+
### File Categories (`app_config.py`)
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
FILE_CATEGORIES = {
|
|
209
|
+
"Images": [".jpg", ".jpeg", ".png", ".gif", ...],
|
|
210
|
+
"Documents": [".pdf", ".doc", ".docx", ".txt", ...],
|
|
211
|
+
"Videos": [".mp4", ".mkv", ".avi", ...],
|
|
212
|
+
"Code": [".py", ".js", ".php", ".ts", ".jsx", ...],
|
|
213
|
+
# Add custom categories here
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Keyword Rules (`rules.py`)
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
KEYWORD_RULES = {
|
|
221
|
+
"invoice": "Documents", # Files with "invoice" go to Documents
|
|
222
|
+
"screenshot": "Images", # Files with "screenshot" go to Images
|
|
223
|
+
# Add custom rules here
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Testing
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Install pytest
|
|
231
|
+
pip install pytest
|
|
232
|
+
|
|
233
|
+
# Run all tests
|
|
234
|
+
pytest tests/ -v
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Automatic Scheduling (Windows Task Scheduler)
|
|
238
|
+
|
|
239
|
+
Run the organizer automatically on a schedule using the included batch script.
|
|
240
|
+
|
|
241
|
+
### Quick Setup
|
|
242
|
+
|
|
243
|
+
1. **Edit `run_organizer.bat`** to customize your source/destination folders:
|
|
244
|
+
|
|
245
|
+
```batch
|
|
246
|
+
"C:\Python314\python.exe" organizer.py --source "%USERPROFILE%\Downloads" --dest "%USERPROFILE%\Downloads" --log-level INFO
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
2. **Create the scheduled task** (run in PowerShell as admin):
|
|
250
|
+
|
|
251
|
+
```powershell
|
|
252
|
+
schtasks /create /tn "Smart File Organizer" /tr "C:\path\to\run_organizer.bat" /sc daily /st 12:00 /f
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT License
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Configuration settings for SFO File Organizer.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import shutil
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
def get_resource_path(relative_path: str) -> str:
|
|
11
|
+
"""Get absolute path to resource, works for dev and for PyInstaller."""
|
|
12
|
+
try:
|
|
13
|
+
# PyInstaller creates a temp folder and stores path in _MEIPASS
|
|
14
|
+
base_path = sys._MEIPASS
|
|
15
|
+
except Exception:
|
|
16
|
+
base_path = os.path.abspath(".")
|
|
17
|
+
return os.path.join(base_path, relative_path)
|
|
18
|
+
|
|
19
|
+
def get_data_dir() -> Path:
|
|
20
|
+
"""Get path to persistent data directory (APPDATA on Windows)."""
|
|
21
|
+
if getattr(sys, 'frozen', False):
|
|
22
|
+
# Running as bundled exe
|
|
23
|
+
app_data = os.getenv('APPDATA')
|
|
24
|
+
if app_data:
|
|
25
|
+
path = Path(app_data) / "SFOFileOrganizer"
|
|
26
|
+
else:
|
|
27
|
+
path = Path(sys.executable).parent / "data"
|
|
28
|
+
else:
|
|
29
|
+
# Running in dev
|
|
30
|
+
path = Path(__file__).parent
|
|
31
|
+
|
|
32
|
+
# Ensure directory exists
|
|
33
|
+
try:
|
|
34
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
35
|
+
except Exception:
|
|
36
|
+
# Fallback to current directory if all else fails
|
|
37
|
+
path = Path(".")
|
|
38
|
+
|
|
39
|
+
return path
|
|
40
|
+
|
|
41
|
+
# Data directory for persistent storage (History, Custom Rules)
|
|
42
|
+
# We use APPDATA to ensure data survives app updates/moves
|
|
43
|
+
APPDATA_PATH = os.environ.get("APPDATA", os.path.expanduser("~"))
|
|
44
|
+
DATA_DIR = Path(APPDATA_PATH) / "SFOFileOrganizer"
|
|
45
|
+
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
|
46
|
+
|
|
47
|
+
# Define paths for data files
|
|
48
|
+
HISTORY_FILE = DATA_DIR / "organizer_history.json"
|
|
49
|
+
CUSTOM_RULES_FILE = DATA_DIR / "custom_rules.json"
|
|
50
|
+
|
|
51
|
+
def initialize_data():
|
|
52
|
+
"""Copy default data files to the persistent DATA_DIR if they don't exist."""
|
|
53
|
+
defaults = [CUSTOM_RULES_FILE.name] # Use .name to get "custom_rules.json"
|
|
54
|
+
for filename in defaults:
|
|
55
|
+
dest_path = DATA_DIR / filename
|
|
56
|
+
if not dest_path.exists():
|
|
57
|
+
source_path = get_resource_path(filename)
|
|
58
|
+
if os.path.exists(source_path) and source_path != str(dest_path):
|
|
59
|
+
try:
|
|
60
|
+
shutil.copy2(source_path, dest_path)
|
|
61
|
+
except Exception:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
initialize_data()
|
|
65
|
+
|
|
66
|
+
# Default directories (in-place organization by default)
|
|
67
|
+
DEFAULT_SOURCE_DIR = str(Path.home() / "Downloads")
|
|
68
|
+
DEFAULT_DEST_DIR = DEFAULT_SOURCE_DIR # Same as source for in-place organizing
|
|
69
|
+
|
|
70
|
+
# File categories and their extensions
|
|
71
|
+
FILE_CATEGORIES = {
|
|
72
|
+
"Images": [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".webp", ".ico", ".tiff"],
|
|
73
|
+
"Documents": [".pdf", ".doc", ".docx", ".txt", ".rtf", ".odt", ".xls", ".xlsx", ".ppt", ".pptx"],
|
|
74
|
+
"Videos": [".mp4", ".mkv", ".avi", ".mov", ".wmv", ".flv", ".webm"],
|
|
75
|
+
"Audio": [".mp3", ".wav", ".flac", ".aac", ".ogg", ".wma", ".m4a"],
|
|
76
|
+
"Archives": [".zip", ".rar", ".7z", ".tar", ".gz", ".bz2"],
|
|
77
|
+
"Code": [".py", ".js", ".html", ".css", ".java", ".cpp", ".c", ".h", ".json", ".xml", ".php", ".ts", ".tsx", ".jsx"],
|
|
78
|
+
"Executables": [".exe", ".msi", ".bat", ".sh", ".app", ".dmg"],
|
|
79
|
+
"Fonts": [".ttf", ".otf", ".woff", ".woff2"],
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Logging settings
|
|
83
|
+
LOG_FILE = "organizer.log"
|
|
84
|
+
LOG_LEVEL = "INFO"
|
|
85
|
+
|
|
86
|
+
# Detailed categories for Smart Context mode (Sub-types for Documents)
|
|
87
|
+
DETAILED_CATEGORIES = {
|
|
88
|
+
# Documents breakdown
|
|
89
|
+
".pdf": "PDFs",
|
|
90
|
+
".doc": "Word Documents", ".docx": "Word Documents",
|
|
91
|
+
".xls": "Spreadsheets", ".xlsx": "Spreadsheets", ".csv": "Spreadsheets",
|
|
92
|
+
".ppt": "Presentations", ".pptx": "Presentations",
|
|
93
|
+
".txt": "Text Files", ".md": "Text Files", ".rtf": "Text Files",
|
|
94
|
+
}
|