A high-performance C++ command-line utility that identifies and removes old or empty files from folders.
- Vansh Vora
- 🧼 Detects and deletes:
- Completely empty files (0 bytes)
- Files older than a set threshold (measured in months)
- 🖥️ High-Performance Concurrent Design: Uses a thread pool (
std::thread), lock structures (std::mutex,std::condition_variable), and atomics (std::atomic) to process files concurrently. - ⚡ Modern Standards: Built utilizing C++17
std::filesystemfor real cross-platform directory traversal and file manipulation.
- Language: C++17
- Standard Libraries:
<filesystem>,<thread>,<mutex>,<atomic>,<queue> - Architecture: Concurrent CLI Application with Task Queues
- Build System: CMake
This project uses CMake, the industry standard for C++ build systems.
# 1. Create a build directory
mkdir build
cd build
# 2. Generate build files
cmake ..
# 3. Compile the project
cmake --build .If you don't have CMake installed, you can compile the single file directly using g++. Ensure you link the threading library (-pthread):
g++ -std=c++17 main.cpp -o folderCleaner -pthreadThis utility features a Dual-Mode CLI, catering to both automated servers and regular users.
If you run the executable by double-clicking it or running it with no arguments, it will launch a friendly, interactive menu:
./folderCleanerIf you pass arguments, it runs instantly without pausing for input, which is perfect for scheduled server automation.
Show Help Menu:
./folderCleaner --helpClean a folder (Files older than 3 months):
./folderCleaner -p "C:/Path/To/Your/Folder"Clean a folder (Files older than 6 months AND empty files):
./folderCleaner -p "C:/Path/To/Your/Folder" -m 6 -e-p,--path <dir>: The directory path to clean (Required)-m,--months <num>: Minimum age in months for files to be deleted (Default: 3)-e,--empty: Also delete completely empty files (0 bytes)-h,--help: Show help message and exit
This project is for educational purposes under the university's capstone program.