BashScript Duplicate File Finder is a Bash script that recursively scans a specified directory to identify duplicate files based on file size and SHA256 hash. It helps you manage storage by listing duplicates and providing options to delete or move them.
- Accurate Detection: Identifies duplicates by comparing file size and SHA256 hash.
- Log Output: Generates a
duplicatesFound.txtfile listing all detected duplicates. - Interactive Options: After scanning, you can:
- Delete all duplicates.
- Move duplicates to a
.duplicatesTempfolder for review. - Keep all files unchanged.
- Flexible: Works on any directory path provided.
- Clone the Repository (or download the script):
git clone https://github.com/Zapwap123/BashScript-Bulk-File-Renamer cd BashScript-Duplicate-File-Finder - Make the Script Executable:
chmod +x duplicateFileFinder.sh
- Ensure Required Tools:
bash(default on most Linux distributions, including Ubuntu)sha256sum(part ofcoreutilspackage)statandfindcommands (standard on Linux)
Run the script with the target directory as an argument:
./duplicateFileFinder.sh /path/to/scanThe script scans the directory, prints duplicates found, and generates a duplicatesFound.txt file in the current working directory.
You will be prompted to choose an action:
- Delete all duplicates: Permanently removes duplicate files.
- Move duplicates: Relocates duplicates to a
.duplicatesTempfolder in the current directory. - Do nothing: Leaves all files unchanged.
To test the script, use the exiting script "downloadTestDuplicateFiles.sh" for testing, it create duplicate files in a directory named "file-organizer-duplicate-test":
chmod +x downloadTestDuplicateFiles.sh
./downloadTestDuplicateFiles.shRun the script on the test directory:
./duplicateFileFinder.sh ./file-organizer-duplicate-test- The script processes only regular files (excludes directories and symlinks).
- Empty files (zero size) are ignored.
- The
.duplicatesTempfolder is created in the directory where the script is run if you choose to move duplicates.
This project is open source and available under the MIT License.