OrganizeByType.sh -- README

What it does (quick notes)

Determines type with file -b --mime-type (e.g., image/jpeg, text/plain).

Builds folders as DEST/<top>/<sub> (e.g., organized/image/jpeg/…).

sed sanitizes folder/file names.

awk parses MIME segments and trims hashes.

Collision-safe: if a filename already exists at the destination, it appends an 8-char md5 suffix.

Null-safe traversal via find … -print0.

Options:

-n: dry-run (no changes; prints planned actions)

-c: copy instead of move (default is move)

Examples

Organize by MIME type, moving files:

./organize_by_mime.sh /data/source /data/organized


See what would happen (no changes):

./organize_by_mime.sh -n /data/source /data/organized


Copy instead of move:

./organize_by_mime.sh -c /data/source /data/organized


If you want a variant that flattens to a single directory per top-level type (e.g., image/, audio/, video/), or one that preserves relative subpaths inside the new structure, say the word and I’ll drop that version too.
