Last active
July 30, 2019 22:46
-
-
Save mbierman/48bf77e2cdda058567bc4c6f14e312a3 to your computer and use it in GitHub Desktop.
renames image files using exif creation
This file contains hidden or 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 | |
| # echo "RSS feed?" | |
| # read FeedName | |
| domain="https://ramahnorcal.smugmug.com" | |
| if [ "$1" = "1" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194176300_3dMVQd&format=rss200" | |
| foldername="Day 1" | |
| elif [ "$1" = "2" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194229497_QTDNrd&format=rss200" | |
| foldername="Day 2" | |
| elif [ "$1" = "3" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194310653_WkDqcz&format=rss200" | |
| foldername="Day 3" | |
| elif [ "$1" = "4" ]; then | |
| path="" | |
| foldername="Day 4" | |
| elif [ "$1" = "5" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194449378_72jMpx&format=rss200" | |
| foldername="Day 5" | |
| elif [ "$1" = "6" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194537264_CsKQ3k&format=rss200" | |
| foldername="Day 6" | |
| elif [ "$1" = "7" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194624340_nJcBLR&format=rss200" | |
| foldername="Day 7" | |
| elif [ "$1" = "8" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194713762_wPWBbz&format=rss200" | |
| foldername="Day 8" | |
| elif [ "$1" = "9" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194821652_G42sk7&format=rss200" | |
| foldername="Day 9" | |
| elif [ "$1" = "10" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=194874767_z23FtH&format=rss200" | |
| foldername="Day 10" | |
| elif [ "$1" = "11" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=195016258_Rxn3Bd&format=rss200" | |
| foldername="Day 11" | |
| elif [ "$1" = "12" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=195010788_jQhdzJ&format=rss200" | |
| foldername="Day 12" | |
| elif [ "$1" = "13" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=195057732_pB3ctn&format=rss200" | |
| foldername="Day 13" | |
| elif [ "$1" = "14" ]; then | |
| path="/hack/feed.mg?Type=gallery&Data=195125703_2T65bx&format=rss200" | |
| foldername="Day 14" | |
| else | |
| path="" | |
| fi | |
| if [ -z "$path" ]; then | |
| echo "no RSS path provided." | |
| open https://ramahnorcal.smugmug.com/Kayitz-2019/Kayitz-2019-Session-3 | |
| exit | |
| fi | |
| if [ -z "$foldername" ]; then | |
| echo "Where do you want to save the files?" | |
| read foldername | |
| exit | |
| fi | |
| FeedName="$domain$path&ImageCount=500&Paging=0" | |
| DEST="$HOME/Downloads/Camp 2019/$foldername/" | |
| echo " Saving to $DEST ...\n\n" | |
| if [ ! -d "$DEST" ]; then | |
| mkdir -p "$DEST" | |
| fi | |
| destcount=$(find "$DEST" -type f -name "*.jpg" -maxdepth 1 | wc -l | sed -e 's| ||g') | |
| if [ "$destcount" -eq "0" ]; then | |
| # Empty | |
| echo "" | |
| else | |
| # Not Empty | |
| echo "$DEST is not empty." | |
| read -p "Do you want to continue? (y|n) ? " -n 1 -r | |
| if [[ ! $REPLY =~ ^[Yy]$ ]] | |
| then | |
| exit | |
| else | |
| mkdir -p "${DEST}/tagged" | |
| mdfind \( 'kMDItemKind = "image" || kMDItemUserTags = "*"' \) -onlyin "$DEST" | xargs -I {} cp {} "${DEST}tagged" | |
| fi | |
| fi | |
| URLs="$(curl "$FeedName" | | |
| grep X3.jpg | | |
| sed -e 's|\<media:content url="||g' | | |
| sed -e 's|\.jpg.*$|.jpg|g' | | |
| sed -e 's| ||g' )" | |
| imageCount="$(echo "$URLs" | | |
| grep -c X3.jpg | | |
| sed -e 's| ||g' )" | |
| if [ "$imageCount" -eq "$destcount" ]; then | |
| echo "\n\nProbably no new images. Continue? (y|n)" | |
| read -n 1 -rs | |
| if [[ ! $REPLY =~ ^[Yy]$ ]] | |
| then | |
| exit | |
| fi | |
| elif [ "$imageCount" -gt "$destcount" ]; then | |
| newImages=$(($imageCount - $destcount)) | |
| echo "\n\n$newImages new images found" | |
| elif [ "$imageCount" -lt "$destcount" ]; then | |
| echo "\n\nWARNING: Fewer images found on smugmug than already downloaded." | |
| read -p "Do you want to continue? (y|n) ? " -n 1 -r | |
| if [[ $REPLY =~ ^[Nn]$ ]] | |
| then | |
| exit | |
| fi | |
| fi | |
| echo "\n\n$imageCount images found on smugmug. Starting download...\n\n" | |
| sleep 3 | |
| cd "$DEST" | |
| for url in $URLs; do | |
| curl -O -# $url | |
| done | |
| if [ -e "${DEST} tagged/"*.jpg ]; then | |
| cp "${DEST} tagged/"*.jpg "${DEST}" | |
| fi | |
| open "$(dirname "$DEST")" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Makes use of homebrew http://johnst.org/sw/exiftags/