DEV Community

Sufal Thakre
Sufal Thakre

Posted on

🛠️Building a Simple File Organizer CLI Using Node.js

When working daily on my system, my Downloads folder keeps getting messy — images, PDFs, videos, code files, all mixed together. Manually organizing them again and again felt unnecessary.

So, as part of an assignment (and also to solve my own problem), I decided to build a simple command-line utility using Node.js.


❓ The Problem

  • Files from browsers, tools, and apps pile up quickly
  • Finding the right file becomes time-consuming
  • Manually creating folders and moving files is repetitive

I wanted a small, reusable tool that could do this automatically.


💡 The Solution

I built a Node.js CLI tool that:

  • Takes a folder path as input
  • Reads all files in that folder
  • Categorizes them based on file extensions
  • Creates folders like:

    • Images
    • Documents
    • Videos
    • Audio
    • Code
    • Archives
  • Moves files into the correct folders safely

It uses only Node.js standard libraries — no external dependencies.


⚙️ Tech Stack

  • Node.js
  • JavaScript (ES Modules)
  • fs module for file operations
  • path module for path handling
  • Command-line arguments via process.argv

▶️ How to Run the Tool

npm install
npm start -- "/path/to/your/folder"
Enter fullscreen mode Exit fullscreen mode

Example:

npm start -- "~/Downloads"
Enter fullscreen mode Exit fullscreen mode

The tool converts the path to an absolute path, validates it, and then starts organizing files.


🧠 Design Decisions

  • Used synchronous file operations for clarity and simplicity
  • Converted relative paths to absolute paths to avoid errors
  • Stored only necessary data in memory
  • Focused on clean and readable logic
  • Built as a CLI tool to keep it lightweight and fast

🎥 Demo Video

I also recorded a short demo video explaining:

  • The problem
  • How the tool works
  • My design choices

📹 Video:

📦 Source Code

GitHub Repository:
👉 https://github.com/Sufalthakre18/file-organizer-cli


🚀 What I Learned

  • Working with the filesystem in Node.js
  • Handling paths correctly across systems
  • Writing CLI-based tools
  • Thinking about real-world usability instead of just features

🙌 Feedback Welcome

This is a simple project, but it solved a real problem for me.
I’d love feedback, suggestions, or ideas to improve it further.

Thanks for reading!

Top comments (0)