Last active
August 21, 2024 19:38
-
-
Save dantleech/222e134c672864617dcb011e98c3b089 to your computer and use it in GitHub Desktop.
Very arbitrary script to sync files from my android phone, resize them, deposit them in my blog's asset folder and displaty the markdown to display the,
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
#!/usr/bin/env bash | |
set -e | |
OUTDIR=$HOME"/blog/static/images/spain2024" | |
mkdir -p $OUTDIR | |
echo "" > markdown | |
# get the "last synced" timestamp | |
TIMESTAMP=`tail -n 1 timestamp || true` | |
# sync new camera assets from the phone | |
adb-sync --reverse /storage/self/primary/DCIM/OpenCamera . | |
# update timestamp of a file to the last-synced timestamp so `find` can ... | |
touch -t $TIMESTAMP marker | |
# ... find images newer than it in the synced folder :/ | |
for image in `find OpenCamera -newer marker -name *.jpg`; do | |
# preview the image | |
imv $image | |
# ask for a label, empty will skip the image | |
read -p "Filename:" LABEL | |
if [ "$LABEL" != "" ]; then | |
FILENAME=$TIMESTAMP-`basename $LABEL`".jpg" | |
convert $image -resize 700x700 $OUTDIR"/"$FILENAME | |
echo "" >> markdown | |
fi | |
done; | |
date +"%Y%m%d%k%M" >> timestamp | |
cat markdown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment