Guest User

Untitled

a guest
Mar 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #!/bin/bash
  2. DIR="$1"
  3.  
  4. # failsafe - fall back to current directory
  5. [ "$DIR" == "" ] && DIR="."
  6.  
  7. # save and change IFS
  8. OLDIFS=$IFS
  9. IFS=$'\n'
  10.  
  11. # read all file name into an array
  12. fileArray=($(find $DIR -type f))
  13.  
  14. # restore it
  15. IFS=$OLDIFS
  16.  
  17. # get length of an array
  18. tLen=${#fileArray[@]}
  19. echo "Number of files $tLen"
  20.  
  21. # use for loop read all filenames
  22. for (( i=0; i<${tLen}; i++ ));
  23. do
  24. thisFile=${fileArray[$i]}
  25. fileType=$(file -b -I ${fileArray[$i]})
  26. if ! [[ $fileType == *"image"* ]]; then
  27. echo "$thisFile is not an image ... skipping"
  28. continue
  29. fi
  30. echo -n "$thisFile "
  31. exiftool "${fileArray[$i]}" -ExifIFD:DateTimeOriginal
  32. #change file Create Date
  33. exiftool -overwrite_original '-CreateDate<DateTimeOriginal' "${fileArray[$i]}"
  34. #change file OS modify date
  35. exiftool -overwrite_original '-FileModifyDate<DateTimeOriginal' "${fileArray[$i]}"
  36. #rename file
  37. exiftool '-FileName<DateTimeOriginal' -d "%Y-%m-%d %H.%M.%S%%-c.%%e" "${fileArray[$i]}"
  38. done
Add Comment
Please, Sign In to add comment