Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DIR="$1"
- # failsafe - fall back to current directory
- [ "$DIR" == "" ] && DIR="."
- # save and change IFS
- OLDIFS=$IFS
- IFS=$'\n'
- # read all file name into an array
- fileArray=($(find $DIR -type f))
- # restore it
- IFS=$OLDIFS
- # get length of an array
- tLen=${#fileArray[@]}
- echo "Number of files $tLen"
- # use for loop read all filenames
- for (( i=0; i<${tLen}; i++ ));
- do
- thisFile=${fileArray[$i]}
- fileType=$(file -b -I ${fileArray[$i]})
- if ! [[ $fileType == *"image"* ]]; then
- echo "$thisFile is not an image ... skipping"
- continue
- fi
- echo -n "$thisFile "
- exiftool "${fileArray[$i]}" -ExifIFD:DateTimeOriginal
- #change file Create Date
- exiftool -overwrite_original '-CreateDate<DateTimeOriginal' "${fileArray[$i]}"
- #change file OS modify date
- exiftool -overwrite_original '-FileModifyDate<DateTimeOriginal' "${fileArray[$i]}"
- #rename file
- exiftool '-FileName<DateTimeOriginal' -d "%Y-%m-%d %H.%M.%S%%-c.%%e" "${fileArray[$i]}"
- done
Add Comment
Please, Sign In to add comment