This script renames and organizes files based on metadata, hash values, and custom naming options. It supports various operations, such as copying or moving files, and can process directories recursively.
- Copy or move files to a specified directory.
- Rename files based on metadata or original filenames.
- Append hash values to filenames using various algorithms (md5, sha1, sha256).
- Support for automatic or manual mode for renaming.
- Recursive directory processing.
- Optional inclusion of version numbers and dates in filenames.
- Verbose and quiet modes for detailed or suppressed output.
./bulk-rename.sh [-d target_directory] [-a hash_algorithm] [-m mode] [-o operation] [-r recursion] [-t title_option] [-q quiet] [-v version] [-D use_date] [-T use_datetime] [files...]
-d target_directory
: Directory to copy/move the files into. If not provided, files are copied/moved into the current directory.-a hash_algorithm
: Hash algorithm to use (md5, sha1, sha256). If not provided, no hash is appended.-m mode
: Mode to use (auto
ormanual
). Default isauto
.-o operation
: Operation to perform (copy
ormove
). Default iscopy
.-r recursion
: Recursion mode (1
to enable,0
to disable). Default is0
.-t title_option
: Title option:filename
(use original filename) ormetadata
(use title from metadata). Default isfilename
.-q quiet
: Quiet mode (1
to suppress output,0
to enable). Default is0
.-v version
: Include version in filename (1
to include,0
to exclude). Default is1
.-D use_date
: Include date in filename (1
to include,0
to exclude). Default is1
.-T use_datetime
: Use full datetime in filename (1
to include,0
to exclude). Default is0
.-h
: Display the help message.
Copy files to the Copy
directory, using md5 hash and metadata for naming:
./bulk-rename.sh -d Copy -a md5 -m auto -t metadata *
Move files to the MovedFiles
directory with verbose output:
./bulk-rename.sh -d MovedFiles -o move *
Suppress output while processing:
./bulk-rename.sh -q 1 *
Process directories and their contents recursively:
./bulk-rename.sh -r 1 *
Exclude version and date from filenames:
./bulk-rename.sh -v 0 -D 0 *
Include full datetime in filenames:
./bulk-rename.sh -T 1 *
exiftool
: Used for extracting metadata from files.md5sum
,sha1sum
,sha256sum
: Used for generating hash values.
Ensure the script is executable:
chmod +x bulk-rename.sh
Install required dependencies on a Debian-based system:
sudo apt-get install exiftool coreutils
This project is licensed under the MIT License.
Feel free to submit issues or pull requests to improve the script.