Last active
August 29, 2015 14:06
-
-
Save ianmacartney/fe13db41ddaa6a9fa83f to your computer and use it in GitHub Desktop.
Move OhLife photos to Day One
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/bash | |
# This script will add a DayOne entry for each photo in your OhLife journal. | |
# It will also rename the photos to have the date in their name for you convenience | |
# 1. Download this gist and open the .tar.gz or whatever it downloaded as. | |
# 2. Go to https://ohlife.com/entries/all and log in | |
# 3. Once the page fully loads, right click the background and click "Save As..." and choose the directory | |
# where this file was downloaded. | |
# This will download all the photos and the html of the page. | |
# 4. If the name of the page was different than NAME below, change NAME below to be the name of the .html file in the directory | |
# 5. on the command line, cd into the directory with this script and run `. OhLifePhotosToDayOne.sh` | |
# 6. Verify that it worked. If there are leftover photos, check to see if your file extension was included in my list (below, starting with jpg) | |
NAME="The easiest way to write your life story OhLife" | |
INDEX="$NAME".html | |
PHOTO_DIR="$NAME"_files | |
mkdir -p renamed | |
for f in "$PHOTO_DIR/"*.{jpg,png,jpeg,tif,tiff,gif,pdf}; do | |
short_f=$(echo $f | cut -f 2 -d /) | |
if [[ `echo $short_f | cut -c-1` != "*" ]]; then | |
DATE=$(grep -C10 "$f" "$INDEX" | grep "<h2>" | cut -c 7- | cut -f 1 -d "<" ) | |
if [[ -n $DATE ]]; then | |
echo "" | dayone -d="$DATE" -p="$f" new | |
mv "$f" "renamed/$DATE-$short_f" | |
fi | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment