Skip to content

orassayag/empty-directories

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

179 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Empty Directories

A Node.js utility application to scan and identify all empty directories from a given path and log them into a TXT file.

Built in April 2021. This simple yet powerful tool helps you clean up your file system by finding directories that contain no files or subdirectories.

Features

  • πŸ“ Recursively scans directories from a specified path
  • πŸ” Identifies all empty directories
  • πŸ“ Generates a detailed log file with all findings
  • βš™οΈ Configurable ignore paths for flexibility
  • πŸ›‘οΈ Interactive confirmation before execution
  • πŸ’Ύ Backup functionality for the application itself
  • πŸ“Š Progress tracking during scan operations

Getting Started

Prerequisites

  • Node.js (v12 or higher)
  • npm

Installation

  1. Clone the repository:
git clone https://github.com/orassayag/empty-directories.git
cd empty-directories
  1. Install dependencies:
npm install

Configuration

Edit the settings in src/settings/settings.js:

  • SCAN_PATH: The absolute path to scan (e.g., C:\\Or\\Web)
  • DIST_FILE_NAME: Name for the output log file (default: result-log)
  • APPLICATION_NAME: Application name for path calculations
  • IGNORE_DIRECTORIES: Directories to exclude from backup operations
  • MILLISECONDS_END_DELAY_COUNT: Delay before exiting (default: 1000ms)

Configure paths to ignore during scan in src/configurations/ignorePaths.js:

module.exports = [
    'node_modules',
    '.git',
    'dist',
    // Add more paths to ignore
];

Available Scripts

Scan

Scans for empty directories and generates a log file:

npm start

Backup

Creates a backup of the application:

npm run backup

Lint

Checks code for linting errors:

npm run lint

Project Structure

empty-directories/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ configurations/  # Configuration files (ignore paths)
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ enums/       # Enumeration definitions
β”‚   β”‚   └── models/      # Data models
β”‚   β”œβ”€β”€ logics/          # Main application logic
β”‚   β”œβ”€β”€ scripts/         # Script executables
β”‚   β”œβ”€β”€ services/        # Business logic services
β”‚   β”œβ”€β”€ settings/        # Application settings
β”‚   β”œβ”€β”€ tests/           # Test files
β”‚   └── utils/           # Utility functions
β”œβ”€β”€ dist/                # Output log files
β”œβ”€β”€ backups/             # Application backups
└── package.json

How It Works

graph TD
    A[Start Application] --> B[Load Settings]
    B --> C[Display Configuration]
    C --> D{User Confirms?}
    D -->|No| E[Exit: Abort by User]
    D -->|Yes| F[Initialize Services]
    F --> G[Start Scan]
    G --> H[Recursive Directory Scan]
    H --> I{Directory Empty?}
    I -->|Yes| J[Add to Results]
    I -->|No| K{Has Subdirectories?}
    K -->|Yes| H
    K -->|No| L{More Directories?}
    J --> L
    L -->|Yes| H
    L -->|No| M[Write Results to File]
    M --> N[Display Statistics]
    N --> O[Exit: Finish]
    
    style A fill:#90EE90
    style E fill:#FFB6C1
    style O fill:#87CEEB
Loading

Application Flow

  1. Configuration Loading: Reads settings from src/settings/settings.js
  2. User Confirmation: Displays key settings and prompts for confirmation
  3. Service Initialization: Initializes all required services (log, path, scan, count limit)
  4. Directory Scanning: Recursively scans the specified path
  5. Empty Detection: Checks each directory for files and subdirectories
  6. Filtering: Applies ignore paths to skip unwanted directories
  7. Logging: Records all empty directories found
  8. Report Generation: Creates a TXT file in the dist/ directory
  9. Cleanup: Performs graceful shutdown with statistics

Usage Example

$ npm start

===IMPORTANT SETTINGS===
SCAN_PATH: C:\Or\Web
DIST_FILE_NAME: result-log
========================
OK to run? (y = yes)
y
===INITIATE THE SERVICES===
===SCAN DIRECTORIES===
C:\Or\Web\OldProject\EmptyFolder
C:\Or\Web\Archive\UnusedDir
C:\Or\Web\TestData\TempDir
===EXIT: FINISH===

The output file dist/result-log.txt will contain:

C:\Or\Web\OldProject\EmptyFolder
C:\Or\Web\Archive\UnusedDir
C:\Or\Web\TestData\TempDir

Development

The project uses:

  • Node.js for runtime
  • fs-extra for enhanced file operations
  • ESLint for code linting
  • readline-sync for user input

Contributing

Contributions to this project are released to the public under the project's open source license.

Everyone is welcome to contribute. Contributing doesn't just mean submitting pull requestsβ€”there are many different ways to get involved, including answering questions and reporting issues.

Please feel free to contact me with any question, comment, pull-request, issue, or any other thing you have in mind.

Author

License

This application has an MIT license - see the LICENSE file for details.

About

A Node.js utility application to scan and identify all empty directories from a given path and log them into a TXT file. Built in April 2021. This simple yet powerful tool helps you clean up your file system by finding directories that contain no files or subdirectories.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors