Skip to content

🧹 Bash script to find and manage duplicate files using file size and SHA256 hash. Offers options to delete or move duplicates after scanning.

Notifications You must be signed in to change notification settings

Zapwap123/BashScript-Duplicate-File-Finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BashScript Duplicate File Finder

Description

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.

Features

  • Accurate Detection: Identifies duplicates by comparing file size and SHA256 hash.
  • Log Output: Generates a duplicatesFound.txt file listing all detected duplicates.
  • Interactive Options: After scanning, you can:
    • Delete all duplicates.
    • Move duplicates to a .duplicatesTemp folder for review.
    • Keep all files unchanged.
  • Flexible: Works on any directory path provided.

Setup Instructions

  1. Clone the Repository (or download the script):
    git clone https://github.com/Zapwap123/BashScript-Bulk-File-Renamer
    cd BashScript-Duplicate-File-Finder
  2. Make the Script Executable:
    chmod +x duplicateFileFinder.sh
  3. Ensure Required Tools:
    • bash (default on most Linux distributions, including Ubuntu)
    • sha256sum (part of coreutils package)
    • stat and find commands (standard on Linux)

Usage

Run the script with the target directory as an argument:

./duplicateFileFinder.sh /path/to/scan

The script scans the directory, prints duplicates found, and generates a duplicatesFound.txt file in the current working directory.

After Duplicate Detection

You will be prompted to choose an action:

  • Delete all duplicates: Permanently removes duplicate files.
  • Move duplicates: Relocates duplicates to a .duplicatesTemp folder in the current directory.
  • Do nothing: Leaves all files unchanged.

Testing the Script

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.sh

Run the script on the test directory:

./duplicateFileFinder.sh ./file-organizer-duplicate-test

Notes

  • The script processes only regular files (excludes directories and symlinks).
  • Empty files (zero size) are ignored.
  • The .duplicatesTemp folder is created in the directory where the script is run if you choose to move duplicates.

License

This project is open source and available under the MIT License.

About

🧹 Bash script to find and manage duplicate files using file size and SHA256 hash. Offers options to delete or move duplicates after scanning.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages