A simple Windows batch script that auto-sorts files in a folder into categorized subfolders.
- Extension-based sorting — each file is routed to a folder based on its extension
- Auto-creates category folders —
Images,Documents,PDFs,Videos,Music,Archives,Installers,Scripts,Othersare created automatically if they don't exist - Skips itself — the script won't move itself into
Scriptswhile running - Silent move — files are moved without confirmation prompts; any errors are suppressed
- Pause on completion — the window stays open so you can see the "Done. Files sorted." message
- Download or clone this repository.
- Place
organize.batinside the folder you want to sort. - Double-click
organize.bat, or run it from the command prompt:
organize.bat- Done. Your files are now sorted into subfolders.
Note: The script only sorts files in the same folder where it is placed. It does not recurse into subfolders.
| Category | Extensions |
|---|---|
| Images | .jpg .jpeg .png .gif .bmp .svg .webp |
| Documents | .doc .docx .txt .xls .xlsx .ppt .pptx .csv |
| PDFs | .pdf |
| Videos | .mp4 .mkv .avi .mov .wmv |
| Music | .mp3 .wav .flac .aac |
| Archives | .zip .rar .7z .tar .gz |
| Installers | .exe .msi |
| Scripts | .bat .ps1 .py .js .sh |
| Others | (anything not listed above) |
- Windows only — requires
cmd.exe - No additional software, runtimes, or dependencies needed
Open organize.bat in any text editor and find the :sort label (around line 28). Add a new line in the appropriate block using this pattern:
if /i "%e%"==".ext" set "dest=Category"Example — to send .ogg files to the Music folder:
if /i "%e%"==".ogg" set "dest=Music"To create a brand new category (e.g. Fonts):
- Add the folder name to the
for %%D in (...)loop at the top of the script so it gets created automatically. - Add your
if /ilines in the:sortsection pointingdestto that new folder name.
- This script moves files — it does not copy them. Once a file is moved, it is no longer in the original location. Back up your folder before running this script for the first time.
- Only top-level files in the same folder as the script are sorted. Files inside existing subfolders are left untouched.
MIT — see LICENSE for details.