A Python command-line tool featuring a Rich-enhanced interface to calculate folder sizes, display them clearly, and optionally rename folders to include their size information.
This utility provides an interactive menu to help you analyze disk space usage by folders. It can:
- Calculate the total size of folders recursively (including all nested content).
- Display sizes in -readable format (KB, MB, GB, etc.).
- Present information clearly using tables, progress bars, and styled text via the
rich
library. - Optionally rename folders (either individually or batch rename subfolders) to append their calculated size.
- ✨ Rich Interface: Enhanced command-line experience with progress bars, spinners, styled text, tables, and panels.
- 💻 Interactive Menu: Simple numerical menu to select actions.
- 📊 Accurate Size Calculation: Recursively scans folders for total size.
- 📈 Readable Sizes: Converts bytes to KB, MB, GB, etc.
- 📑 Three Core Actions:
- List Subfolder Sizes: Select a parent directory → view sizes of its immediate subfolders.
- Rename Multiple Subfolders: Select a parent directory → calculate subfolder sizes → confirm → rename subfolders to
FolderName [Size]
. - Analyze & Rename Single Folder: Select a specific folder → calculate its size → confirm → rename the folder itself to
FolderName [Size]
.
- 🪟 Graphical Folder Selection: Uses built-in Tkinter for easy folder selection dialogs.
- 🛡️ Safety Features:
- Confirmation Prompts: Critical prompts before any potentially destructive renaming action.
- Skip Existing: Attempts to detect and skip renaming folders that already appear to have a size appended (
[Size Units]
format). - Path Length Check: Prevents renaming if the resulting path might exceed common OS limits.
- Target Exists Check: Avoids overwriting if a folder with the proposed new name already exists.
⚠️ Error Handling: Basic handling for permission errors or inaccessible files/folders during scans.
The renaming features (Options 2 and 3) permanently modify folder names on your filesystem. This action cannot be easily undone automatically.
- 🛑 BACK UP YOUR DATA before using the rename features on important directories.
- 🧪 TEST the script on non-critical folders first to understand its behavior.
- 👀 REVIEW the proposed renames carefully before confirming.
- Python 3.x (Developed with Python 3.7+)
- Rich: For the enhanced terminal UI. Install via pip:
pip install rich
- Tkinter: Required for the graphical folder selection dialogs.
- Usually included with standard Python installations on Windows and macOS.
- On some Linux distributions, you might need to install it separately (e.g.,
sudo apt-get update && sudo apt-get install python3-tk
on Debian/Ubuntu).
- Download/Clone: Get the script file (e.g.,
DirSizer.py
) onto your computer. - Open Terminal/Command Prompt: Launch your terminal (macOS/Linux) or command prompt (Windows).
- Navigate: Use the
cd
command to go to the directory where you saved the script file.cd path/to/your/script/directory
- Run Script: Execute the script using Python 3.
(You might need to use
DirSizer.py
python3
instead ofpython
depending on your system setup) - Use Menu: The script will display the main menu in your terminal. Enter the number corresponding to the action you want (1, 2, 3, or 4 to exit).
- Select Folder: A graphical folder selection window will pop up when needed. Choose the appropriate directory based on the selected menu action.
- Follow Prompts: Read the output in the terminal. Size calculations might take time for large folders (progress bars will be shown).
- Confirm Renames: If using options 2 or 3, carefully review the proposed changes displayed in the terminal table, then explicitly confirm the action in the pop-up dialog box before any folders are renamed.
- Return to Menu: After completing an action, press Enter to return to the main menu.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions, issues, and feature requests are welcome! Please feel free to open an issue or submit a pull request.