Created
May 9, 2019 00:24
-
-
Save simongcc/31978b96b310d86d104d55c1ea44d705 to your computer and use it in GitHub Desktop.
Export Exif files from jpeg using shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# #!/bin/sh is called shebang | |
# ref: https://en.wikipedia.org/wiki/Shebang_(Unix) | |
# #!/usr/bin/env bash means looking into the path and call the first bash found in the path | |
# ref: https://unix.stackexchange.com/questions/29608/why-is-it-better-to-use-usr-bin-env-name-instead-of-path-to-name-as-my | |
# bash script if or | |
# ref: https://stackoverflow.com/questions/3826425/how-to-represent-multiple-conditions-in-a-shell-if-statement | |
# check file extension | |
# ref: https://stackoverflow.com/questions/407184/how-to-check-the-extension-of-a-filename-in-a-bash-script | |
# check file exist | |
# ref: https://linuxize.com/post/bash-check-if-file-exists/ | |
# shell parameter expansion (eg. remove string pattern) | |
# ref: http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html | |
# ref: https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash | |
# dependency: exiftool install | |
# tested in OSX 10.12.6 terminal shell | |
#!/usr/bin/env bash | |
for FILE in *.*; | |
do | |
filename=$(basename -- "$FILE"); | |
extension="${filename##*.}"; | |
filename="${filename%.*}" | |
# echo $filename.txt | |
# check exist | |
if test -f "$FILE"; then | |
# echo "$FILE exist"; | |
if [[ $FILE == *.JPG || $FILE == *.jpg ]]; then | |
# echo "$FILE is jpg"; | |
exiftool $FILE > $filename.txt; | |
fi | |
fi | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment