juan.ca
← All projects

organize

Live

Flatten nested directories in one command

organize flatten photos --delete
photos/vacation/day1/img001.jpg  ->  photos/img001.jpg
photos/vacation/img002.jpg       ->  photos/img002.jpg
photos/birthday/cake.jpg         ->  photos/cake.jpg
Source (opens in a new tab)
Kind
Command-line tool
Platforms
macOS, Linux
Stack
  • Rust
Active
Dec 2025

Highlights

  • Moves every nested file up to the top level
  • Adds numeric suffixes when names collide
  • --rename prefixes each file with its parent folder's name
  • --delete removes the empty folders left behind

organize flattens a directory tree: every file in every subfolder moves up to the top level. When two files share a name, the later ones get numeric suffixes, so file.txt sits beside file_1.txt and file_2.txt.

--rename prefixes each file with its parent folder’s name, turning 2024/January/img.jpg into January_img.jpg, and --delete removes the empty folders left behind. It moves files in place with no preview, so I try it on a copy first. It’s written in Rust.