Skip to content

zoza1982/file-organizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

file-organizer

A fast, flexible command-line tool to automatically organize files into folders based on various strategies.

Features

  • Multiple organization strategies: Organize files by extension, date, size, or type
  • Dry-run mode: Preview changes before applying them
  • Recursive processing: Optionally process subdirectories
  • Conflict handling: Automatically renames files to avoid overwrites
  • Zero dependencies: Uses only Go standard library

Installation

From source

git clone https://github.com/file-organizer/file-organizer.git
cd file-organizer
go build -o file-organizer .

Using go install

go install github.com/file-organizer@latest

Usage

file-organizer [options]

Options

Flag Description Default
-source Source directory to organize . (current directory)
-dest Destination directory Same as source
-strategy Organization strategy extension
-dry-run Preview changes without moving files false
-recursive Process subdirectories false
-verbose Show detailed output false
-version Show version information

Strategies

extension (default)

Organizes files by their file extension.

Downloads/
  ├── report.pdf
  ├── photo.jpg
  └── notes.txt

# After: file-organizer -source Downloads -strategy extension

Downloads/
  ├── pdf/
  │   └── report.pdf
  ├── jpg/
  │   └── photo.jpg
  └── txt/
      └── notes.txt

date

Organizes files by modification date (YYYY/MM format).

Photos/
  ├── vacation.jpg     (modified: 2024-06-15)
  ├── birthday.jpg     (modified: 2024-01-20)
  └── christmas.jpg    (modified: 2023-12-25)

# After: file-organizer -source Photos -strategy date

Photos/
  ├── 2024/
  │   ├── 06/
  │   │   └── vacation.jpg
  │   └── 01/
  │       └── birthday.jpg
  └── 2023/
      └── 12/
          └── christmas.jpg

size

Organizes files by size categories.

Category Size Range
tiny < 10 KB
small 10 KB - 1 MB
medium 1 MB - 100 MB
large 100 MB - 1 GB
huge > 1 GB
Files/
  ├── config.txt       (500 bytes)
  ├── document.pdf     (2 MB)
  └── video.mp4        (500 MB)

# After: file-organizer -source Files -strategy size

Files/
  ├── tiny (< 10KB)/
  │   └── config.txt
  ├── medium (1MB - 100MB)/
  │   └── document.pdf
  └── large (100MB - 1GB)/
      └── video.mp4

type

Organizes files by type category.

Category Extensions
documents pdf, doc, docx, txt, xls, xlsx, ppt, pptx, etc.
images jpg, png, gif, svg, webp, heic, psd, etc.
videos mp4, avi, mkv, mov, webm, etc.
audio mp3, wav, flac, aac, ogg, etc.
archives zip, rar, 7z, tar, gz, etc.
code go, py, js, ts, java, c, cpp, html, css, json, etc.
executables exe, msi, app, apk, jar, etc.
fonts ttf, otf, woff, woff2, etc.
other Everything else

Examples

Organize Downloads folder by extension

file-organizer -source ~/Downloads -strategy extension

Preview organization without moving files

file-organizer -source ~/Downloads -strategy type -dry-run

Organize photos by date to a different folder

file-organizer -source ~/Photos -dest ~/Photos/Organized -strategy date

Recursively organize with verbose output

file-organizer -source ~/Documents -strategy type -recursive -verbose

Testing

Run the test suite:

go test ./...

Run with verbose output:

go test -v ./...

License

MIT License - see LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages