A lightweight, efficient command-line utility written in C that organizes clutter in your directories by moving files into subfolders based on their file extensions.
- Blazing Fast: Uses
uthashfor O(1) extension lookup. - Automatic Sorting: Automatically categorizes files into common folders like
Documents,Images,Videos, andCode. - Lightweight: Minimal dependencies and small memory footprint.
Currently, the organizer supports the following mappings out-of-the-box:
| Category | Extensions |
|---|---|
| Documents | .pdf, .docx, .doc, .txt, .pptx, .ppt, .xlsx, .xls, .csv, .json, .yaml, .xml, .epub, .mobi, .ttf, .woff, .otf |
| Images | .jpg, .jpeg, .png, .gif, .svg, .webp, .bmp, .ico, .tiff, .tif, .eps |
| Videos | .mp4, .mkv, .avi, .mov, .wmv, .flv, .webm, .m4v |
| Music | .mp3, .wav, .flac, .m4a, .ogg, .aac, .wma |
| Code | .c, .cpp, .h, .py, .js, .ts, .java, .go, .rs, .php, .html, .css, .sql |
| Archives | .zip, .tar, .rar, .7z, .gz, .bz2, .iso, .dmg |
| Executables | .exe, .sh, .bat, .msi |
main.c: Entry point and command-line argument handling.file_utils.c: Handles directory traversal and file movement.hashmap_services.c: Manages the extension-to-folder mapping usinguthash.extensions.c: Defines the default list of extensions and their target folders.include.h: Header file containing constants and struct definitions.compile: A script to compile the project.
To compile this project, you need:
- GCC (or any C compiler)
You can build the project using the provided compilation script:
chmod +x compile
./compileThis will generate an executable named run.
Run following commands in directory with project:
mkdir build
cd build
cmake -S .. -B .
makeRun the program by providing the path to the folder you want to organize:
./run "/path/to/your/cluttered/folder"If you have a folder with the following files:
report.pdfvacation.jpgmain.c
Running the organizer will sort them into:
Documents/report.pdfImages/vacation.jpgCode/main.c
Currently, the extension-to-folder mapping is defined in extensions.c:
struct Mapping defaults[] = {
{"pdf", "Documents"},
{"jpg", "Images"},
{"png", "Images"},
{"c", "Code"},
{"mp4", "Videos"}
};You can modify this file and recompile to customize your organization logic.
Contributors can easily expand the organizer's capabilities by following these steps:
-
Locate
extensions.c: This is where the core mapping between file extensions and destination folders resides. -
Update the
defaultsarray: Add a new entry to thedefaultsstruct array. Each entry follows this format:{"extension", "DestinationFolder"}- Extension: The file extension (without the dot, e.g.,
"pdf","mp3"). Max length is 10 characters. - DestinationFolder: The name of the folder where these files should be moved (e.g.,
"Documents","Music"). Max length is 20 characters.
Example:
struct Mapping defaults[] = { {"pdf", "Documents"}, {"mp3", "Music"}, // Added New Extension // ... other entries };
- Extension: The file extension (without the dot, e.g.,
-
Recompile: After editing the file, run the compilation script to apply your changes:
./compile
This project is open-source. Feel free to use and modify it!