A simple Node.js script that organizes files in the current directory by extension, deletes empty files, and removes files older than thresold years.
- Move files into subfolders based on their extension:
- Images:
IMAGES - PDFs:
PDFs - Word docs:
WORD - Text:
TEXT - Presentations:
PRESENTATIONS - Spreadsheets:
SPREADSHEETS - Code:
CODE
- Images:
- Delete empty files (zero‐length content).
- Skip the script files and common config files (
clutterManager.js,FileToFolder.js,package.json, etc.). - Configurable age limit: Easily set the file age threshold (in years) for deletion by modifying the
ageLimitvariable inclutterManager.js.
-
Place
clutterManager.jsandFileToFolder.jsin the folder you want to organize. or you can just clone it and then place all your files in that directory . -
(Required) Initialize a Node.js project (creates
package.json):npm init -y
-
(Optional) Adjust the following settings inside
clutterManager.js:ageLimitYears: Set how old a file (in years) must be before it's deleted.const ageLimitYears = 2; // Deletes files older than 2 years
-
(Optional) Add or update file-type mappings in
FileToFolder.js:- Example:
const corr_folder = { ".pdf": "PDFs", ".jpg": "IMAGES", ".txt": "TEXT", // Add more extensions as needed };
- Example:
-
Open a terminal in the project folder and run the script:
node clutterManager.js
- Node.js v14 or higher.