Skip to content

justin2061/Folder_analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Directory Tree Analyzer

English | 繁體中文

A PowerShell script tool for analyzing and visualizing directory structures and disk space usage.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Features

  • Recursive analysis of directory structures and file sizes
  • Customizable analysis depth
  • Color-coded output for intuitive size visualization
  • Automatic report generation and text file saving
  • Smart sorting: prioritizes larger directories
  • Automatic unit conversion support (GB, MB, KB, Bytes)

Usage

  1. When executing the script, you'll be prompted to input:

    • Target drive or path to analyze (e.g., C:)
    • Directory depth to analyze (default is 2)
  2. Analysis results will be:

    • Displayed in real-time in the terminal
    • Automatically saved to a text file on the desktop

Output Format

Color Coding

  • Red: Size greater than 1GB
  • Yellow: Size greater than 100MB
  • Cyan: Size less than 100MB

Directory Tree Format

|--Documents [2.5 GB]
|   |--Work [1.2 GB]
|   |--Personal [800 MB]

Technical Details

Main Function

The Get-DirectoryTreeWithSize function includes the following parameters:

  • Path: Target path to analyze (required)
  • MaxDepth: Maximum analysis depth (default: 3)
  • CurrentDepth: Current recursion depth
  • Indent: Indentation string
  • OutputFile: Output file stream

Core Implementation Features

  1. Size Calculation:

    • Recursive calculation of directory and subdirectory sizes
    • Automatic unit conversion for appropriate display
  2. Smart Filtering:

    • Only processes directories larger than 10MB
    • Optimizes performance by avoiding small directory analysis
  3. Error Handling:

    • Path existence verification
    • File access permission handling
    • Output file creation exception handling
  4. Report Generation:

    • Timestamp-based report filename generation
    • UTF-8 encoding support
    • Includes analysis time, path, and detailed information

Important Notes

  1. Sufficient permissions are required to access target paths
  2. Analysis of large directories may take considerable time
  3. Output files are automatically saved to the user's desktop
  4. Recommended to run from a PowerShell terminal with administrator privileges

System Requirements

  • Windows Operating System
  • PowerShell 5.0 or newer
  • Execution policy must allow PowerShell script execution

About

analyzing and visualizing directory structures and disk space usage.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published