Skip to content

Instantly share code, notes, and snippets.

@machiq
Last active June 26, 2019 18:00
Show Gist options
  • Save machiq/dc94b48af4cd20fe29206178c4732a27 to your computer and use it in GitHub Desktop.
Save machiq/dc94b48af4cd20fe29206178c4732a27 to your computer and use it in GitHub Desktop.
Still Image - Export Subject MetaData to CSV and then give option to remove embedded MetaData
#!/bin/bash
#File: stillImage-exportCSV-removeMeta
#
#2019-01-11 Matt Crnich - Hacking on it
#2019-01-15 Matt Crnich - Removed find process in favor of exiftool native functionality
#2019-01-15 Matt Crnich - Adding function to remove metadata from files
#exiftool -IFD1:XResolution -IFD1:YResolution image.jpg
#Extract image resolution from EXIF IFD1 information (thumbnail image IFD).
#exiftool -b -xmp:Subject image.jpg
# -b lists only results without the xmp "Subject" and colon
# example
#
# exiftool -csv -CreateDate -Keywords -r -ext jpg /absolute/path/to/top/folder > data.csv
echo "ENTER SEARCH PATH : "
read srcImagePath
echo
echo "ENTER SEARCH EXTENSION : "
read fileExt
echo
today=`date +%Y-%m-%d_%H_%M_%S`
exiftool -if '$filename !~ /^\./' -csv -FileName -FileType -FileSize -xmp:Subject -r -ext "$fileExt" "$srcImagePath" > "$srcImagePath/extractedMetaData_$today.csv"
echo
read -e -p "DO YOU WANT TO REMOVE ALL METADATA? [y/n]: " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# exiftool -r -all= -ext jpg -ext gif -ext png /path/to/top/directory/
exiftool -r -all= -preserve -overwrite_original -ext "$fileExt" "$srcImagePath"
else
echo "METADATA LEFT INTACT, GOODBYE"
echo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment