The Ultimate JavaScript File Organizer System


Do you ever find yourself struggling to keep your files organized? Are you tired of sifting through a cluttered mess of documents, images, videos, and code files? Look no further! In this blog post, we’ll introduce you to Filesystem-Organize, a powerful JavaScript code that can revolutionize the way you manage your files. This handy tool automates the process of sorting your files into designated folders based on their file extensions, saving you time and effort. Let’s dive into the world of Filesystem-Organize Will and explore how it can make your life more organized and efficient.

What is Filesystem-Organize?

Filesystem-Organize is a JavaScript code that utilizes the “fs” module (file system) and the “path” module in Node.js. It provides a simple yet effective solution to automatically organize files within a specified folder based on their file extensions. With this code, you no longer have to manually sort through files and drag them to the appropriate folders. Instead, Filesystem-Organize will do the job for you, efficiently categorizing your files into folders such as Music, Documents, Archives, Videos, Apps, Images, Java, JavaScript, HTML, and more.

How Does Filesystem-Organize Work?

Filesystem-Organize operates through the command line, taking the folder path as input. Once you run the code, it checks whether the given folder path exists using the “fs.existsSync()” method. If the folder exists, the code proceeds to read the contents of the folder using “fs.readdirSync()”.

The real magic of Filesystem-Organize lies in its “extensions” object, which contains predefined file extensions as keys and their corresponding folder names as values. For example, the key “python” contains the value “[‘.py’]” to specify that Python files should be stored in the “python” folder. The code uses this object to identify the appropriate folder for each file based on its extension.

Defining File Extensions and Folders

Filesystem-Organize covers a wide range of file extensions and their respective folders, making it versatile for various file types. The code comes preconfigured with extensions such as “.mp3” for Music files, “.docx”, “.pdf”, and others for Documents, “.mp4” and “.mkv” for Videos, and so on. You can easily customize this object to fit your specific needs. For instance, if you work with TypeScript files frequently, you can add the “.ts” extension to the “javascript” key to have them organized in a separate folder.

Sorting and Moving Files

Once Filesystem-Organize reads the files within the given folder, it proceeds to sort each file based on its extension. The code iterates through each file and extracts its extension using the “path.extname()” method. It then calls the “givFoldername()” function, which matches the file extension to the corresponding folder key in the “extensions” object.

If the folder for the specific file extension already exists, the code uses the “moveFile()” function to move the file from the source folder to its designated folder. If the folder doesn’t exist, the code creates one using the “fs.mkdirSync()” method and then moves the file.

Benefits of Using Filesystem-Organize

The benefits of Filesystem-Organize are numerous. Firstly, it saves a significant amount of time and effort by automating the file organization process. No longer do you need to manually categorize each file; the code does it seamlessly for you. Secondly, it ensures your files are neatly organized and easy to locate, enhancing your productivity and workflow.

Moreover, Filesystem-Organize minimizes the risk of losing files amidst a disorganized folder structure. By having files sorted into appropriate folders, you can easily back up and manage them. Additionally, the code’s versatility allows you to add or modify file extensions and folders, catering to your unique requirements.

Installing and Running Filesystem-Organize

Using Filesystem-Organize is straightforward. To get started, ensure you have Node.js installed on your system. Then, follow these steps:

Step 1: Copy the provided code into a new JavaScript file (e.g., “organize.js”).

Step 2: Open your terminal or command prompt and navigate to the folder containing “organize.js.”

Step 3: Run the code with the following command:

node organize.js <folder-path>

Replace “<folder-path>” with the path of the folder you want to organize.

Customizing File Extensions and Folders

One of the great features of Filesystem-Organize is its flexibility in accommodating your specific file organization needs. By modifying the “extensions” object, you can add, remove, or customize file extensions and their corresponding folders.

For example, suppose you frequently work with C++ files (extension “.cpp”) and want to create a separate folder for them. Simply add the following entry to the “extensions” object:

CPlusPlus: ['.cpp']

Then, when you run Filesystem-Organize, it will automatically categorize “.cpp” files into the newly created “CPlusPlus” folder.

A Step Towards a More Organized Digital Life

Adopting Filesystem-Organize is more than just a coding practice; it’s a step towards creating an organized and efficient digital environment. By keeping your files neatly sorted, you not only save time searching for specific files but also reduce the risk of accidentally misplacing or deleting important documents.

Whether you’re a software developer, designer, student, or anyone dealing with a multitude of digital files, Filesystem-Organize can streamline your file management process and bring order to your digital chaos.


Filesystem-Organize is a game-changer for anyone looking to maintain a tidy and organized digital workspace. By harnessing the power of JavaScript, this code offers a simple yet effective solution for automatically sorting files based on their extensions into designated folders. With Filesystem-Organize at your disposal, you can say goodbye to the days of searching through disarrayed folders and welcome a more efficient and productive file management system.

So, take the leap into a more organized digital life and give Filesystem-Organize a try. Your future self will thank you for it!

Source Code

let fs = require("fs");
let path = require("path");

// taking folder path
let folderpath = process.argv[2];

let folderexsist = fs.existsSync(folderpath);
// object
let extensions = {


// reading fill extansion
    console.log("Path is Valid!!!!!!");
    let files = fs.readdirSync(folderpath);
    // console.log(files);
    for(let i=0; i<files.length; i++){
        let ext = path.extname(files[i])
        let NameOfFolder=givFoldername(ext);
        // console.log("Ext--",ext,"Folder--",NameOfFolder);
        let pathOfFolder = path.join(folderpath,NameOfFolder)
        let exist = fs.existsSync(pathOfFolder)

    console.log("Pathe is Invalid !!!!!");
// file delong to which folder camparing file extanstion
function givFoldername(ext){
    for(let key in extensions ){
        let extArr = extensions[key];
        for(let i=0; i<extArr.length; i++){
                return key;
    return "other";
function moveFile(folderpath,pathOfFolder,fileName){
    let sourcePath = path.join(folderpath,fileName);
    let destnationPath = path.join(pathOfFolder,fileName);

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top