File Organizer
Build a Java command-line tool that tidies a messy folder, such as Downloads, by moving files into subfolders by type: images, documents, music, videos, archives and so on. It always shows a preview of every planned move first and only moves files after you confirm, never overwrites a file (adding a number to the name instead), and writes a log of every move so the whole operation can be undone with one command. It's a good first Java project: you'll learn the java.nio.file API (Path and Files), walking folders, maps for grouping, handling name conflicts, reading user input, writing and reading a log file, and testing with JUnit and temporary folders.
- Estimate
- ~7.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
java.nio.file · JUnit 5
Project roadmap
- 01
Define the rules
~1hWrite README.md: the command (organize FOLDER, with --dry-run, --yes and --undo), the categories and their extensions (such as Images for jpg, png and gif, Documents for pdf, docx and txt) with Other for unknown ones, what's skipped (hidden files, folders and the log file itself), how name conflicts are handled (photo.jpg becomes photo (1).jpg), and the log format. Create a Maven or Gradle project. Done when: README.md defines the rules and commands.
- 02
Plan the moves
~1.5hList the files directly in the folder with Files.list (closing the stream), skipping hidden files and folders, and work out each file's category from its lowercase extension using a Map. Build a list of planned moves (from and to), resolving name conflicts with files already in the target folders or planned earlier. Done when: the plan for a test folder lists the right destination for every file.
- 03
Preview and confirm
~1hPrint the plan grouped by category with the number of files, and ask for confirmation with Scanner (skipped with --yes, and with --dry-run nothing is moved). Show a message when there's nothing to organize. Done when: the preview is clear, and nothing moves without confirmation.
- 04
Move files and log them
~1.5hCreate the category folders with Files.createDirectories, and move each file with Files.move, catching errors per file (such as a file in use or no permission) and continuing with the others. Write each successful move as a line in a log file in the folder (the time, the old and new path). Print a summary of moved and failed files. Done when: files are moved into category folders, and the log records every move.
- 05
Undo
~1hImplement --undo, which reads the log from the last run and moves each file back (in reverse order), skipping files that no longer exist where expected and reporting them, then removes category folders that became empty. Done when: organizing then undoing restores the folder exactly as it was.
- 06
Test it
~1.5hWrite JUnit 5 tests using @TempDir: category detection (including upper-case extensions and files without one), name conflicts, dry runs moving nothing, hidden files skipped, the log contents, and undo restoring everything. Done when: all tests pass.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack