This repository contains Python scripts to batch extract compressed files and rename folders in a directory.
-
uncompress.py
- Extracts
.zip
,.tar
,.tar.gz
,.tgz
, and.rar
files. - Deletes original compressed files after extraction.
- Logs all operations in
extraction_log.txt
.
- Extracts
-
rename_folders.py
- Recursively removes a given string from all folder names in a directory.
- Can be run independently or after
uncompress.py
.
-
main.py
- Master script to run
uncompress.py
and thenrename_folders.py
in sequence. - Can pass parameters like the target folder and string to remove.
- Master script to run
-
Python 3.7+
-
Python packages:
pip install rarfile
-
For .rar files, you need the UnRAR executable: Windows
- Download the command-line version of UnRAR from Rarlab.
- Extract UnRAR.exe to a folder, e.g., C:\Program Files\UnRAR.
- Add the folder to your PATH environment variable or set it in the script:
import rarfile
rarfile.UNRAR_TOOL = r"C:\Program Files\UnRAR\UnRAR.exe"
- Without UnRAR, .rar files will be skipped and the script will continue with other formats.
- The scripts log all actions in extracted_files/extraction_log.txt.
- .rar extraction requires UnRAR; other formats work out of the box.
- Make sure the scripts are in the same folder if using main.py.
MIT License