smart-file-organizer
Version:
Intelligent CLI tool for automatically organizing files by type with preview, logging, and undo functionality
214 lines (152 loc) β’ 5.81 kB
Markdown
# ποΈ Smart File Organizer
An intelligent CLI tool that automatically organizes your files by type with preview functionality, detailed logging, and smart categorization.



## β¨ Features
- π **Preview Mode** - See what will happen before making changes
- π **Smart Categorization** - Automatically sorts 50+ file types into logical folders
- π **Detailed Logging** - Track all operations with timestamps
- β‘ **Fast & Efficient** - Process hundreds of files in seconds
- π‘οΈ **Safe Operation** - Confirms before making changes, excludes system files
- π― **Customizable** - Configure your own file type rules
- π **Statistics** - See exactly what was moved and created
## π Quick Start
### Installation
```bash
# Install globally via npm
npm install -g smart-file-organizer
# Or run directly with npx
npx smart-file-organizer
```
### Basic Usage
```bash
# Organize current folder
organize-files
# Preview changes first
organize-files --preview
# Organize specific folder
organize-files ~/Downloads
# Show help
organize-files --help
```
## π Usage Examples
### Organize Downloads Folder
```bash
organize-files ~/Downloads --preview
# Preview what will happen, then:
organize-files ~/Downloads
```
### Organize Desktop with Preview
```bash
organize-files ~/Desktop -p
```
### Get Help
```bash
organize-files --help
```
## π File Categories
The organizer automatically sorts files into these categories:
| Category | File Types |
| --------------------- | ----------------------------------------------------- |
| πΈ **bilder** | `.jpg`, `.png`, `.gif`, `.svg`, `.webp`, `.tiff` |
| π **dokumenter** | `.pdf`, `.doc`, `.docx`, `.txt`, `.rtf`, `.odt` |
| π **regneark** | `.xls`, `.xlsx`, `.csv`, `.ods` |
| π½οΈ **presentasjoner** | `.ppt`, `.pptx`, `.odp` |
| π΅ **lyd** | `.mp3`, `.wav`, `.flac`, `.aac`, `.ogg`, `.m4a` |
| π¬ **video** | `.mp4`, `.avi`, `.mkv`, `.mov`, `.wmv`, `.webm` |
| π¦ **arkiv** | `.zip`, `.rar`, `.7z`, `.tar`, `.gz`, `.bz2` |
| π» **kode** | `.js`, `.ts`, `.html`, `.css`, `.py`, `.java`, `.cpp` |
| π **ebook** | `.epub`, `.mobi`, `.azw`, `.fb2` |
| π€ **font** | `.ttf`, `.otf`, `.woff`, `.woff2` |
| π **andre** | All other file types |
## π οΈ Command Line Options
| Option | Short | Description |
| ----------- | ----- | -------------------------------------------- |
| `--preview` | `-p` | Show what will happen without making changes |
| `--help` | `-h` | Display help information |
| `--config` | `-c` | Show current configuration |
## π Logging
All operations are logged to `file-organizer.log` with timestamps:
```
[2025-01-15T10:30:15.123Z] INFO: Opprettet mappe: bilder
[2025-01-15T10:30:15.456Z] INFO: Flyttet: vacation.jpg til bilder/
[2025-01-15T10:30:15.789Z] INFO: Flyttet: report.pdf til dokumenter/
```
## π§ Configuration
Create a `file-organizer.config.json` file to customize categories:
```json
{
"categories": {
"mine-bilder": [".jpg", ".png", ".heic"],
"mine-dokumenter": [".pdf", ".docx"]
},
"excludeFiles": ["important.txt"],
"logFile": "my-organizer.log"
}
```
## π Example Output
```
ποΈ File Organizer CLI v1.0
============================
π Organiserer: /Users/username/Downloads
π Oversikt over endringer:
π bilder/ (15 filer)
β’ vacation-photo1.jpg
β’ screenshot.png
β’ logo.svg
... og 12 til
π dokumenter/ (8 filer)
β’ report.pdf
β’ invoice.docx
β’ notes.txt
... og 5 til
β Vil du fortsette? (y/N): y
π Starter organisering...
π vacation-photo1.jpg β bilder/
π report.pdf β dokumenter/
π song.mp3 β lyd/
β
Organisering fullfΓΈrt!
π Statistikk:
β’ Filer flyttet: 23
β’ Mapper opprettet: 4
β’ Feil: 0
β’ Tid brukt: 0.15s
```
## π§ͺ Development
### Prerequisites
- Node.js 16+
- npm or yarn
### Setup
```bash
git clone https://github.com/yourusername/smart-file-organizer.git
cd smart-file-organizer
npm install
```
### Testing
```bash
npm test
```
### Local Development
```bash
npm run dev
```
## π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the project
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## π Issues
Found a bug? Have a feature request? Please [open an issue](https://github.com/yourusername/smart-file-organizer/issues).
## π License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## π Acknowledgments
- Built with β€οΈ using Node.js
- Inspired by the need for better file organization
- Thanks to the Node.js community
## β Show your support
Give a βοΈ if this project helped you organize your files!
---
**Made with π» and β by [Marcus](https://github.com/yourusername)**