Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #If a user omits either of the two arguments it displays a helpful message and terminates.
- if [ $# -ne 2 ]; then
- echo "usage: Phar image_path archive_path"
- exit
- fi
- #If the archive directory does not exist the scripts creates it.
- if [ ! -d "$2" ]; then
- mkdir "$2"
- fi
- #If the image source directory does not exist the script reports this error and terminates.
- if [ ! -d "$1" ]; then
- echo "source directory does not exist"
- exit
- fi
- #Loops through every file in $1 that matches 'IMG_[0-9][0-9][0-9][0-9]\.JPG'.
- while in "$(find "$1" -name 'IMG_[0-9][0-9][0-9][0-9]\.JPG')";do
- filename=${-12}
- echo "lll"
- #If statement is used to check if there is a file in $2 that matches filename. And if it does not it copies to $2.
- #readlink gets the absolute path of the duplicate and sends it duplicate text file.
- #if there is already a file with that name but not identical it adds .jpg to avoid overwriting it.
- if [ ! -e "${2}"/"${filename}" ];
- then cp -- "$" "$2"
- echo "$filename is being copied";
- else
- if cmp "$" "$2"/"$filename"; then
- echo "rrrr"
- readlink -f "$" >> "$2"/duplicates.txt
- else cp "$" "$.JPG"
- mv "$".JPG "$2"
- fi
- fi
- done
- #
- if [[ $$ -gt 2 ]]; then
- echo "Can not run more than one process at a time"
- exit
- fi
- if expr match "$1" "$2">/dev/null; then
- echo "error"
- exit
- elif expr match "$2" "$1" >/dev/null; then
- echo "error"
- exit
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement