#!/usr/bin/env bash MNT=/media/swhitton/Kindle DEST="$HOME/tmp/Kindle notes" # kindle=$(blkid | awk -F: '/Kindle/ { print $1; exit; }') filename=$(date +kindle_%F_%H%M.txt) group=$(groups | awk '{print $1}') mkdir -p "$DEST" # sudo umount $kindle # sudo mount -ouid=$(id -u) $kindle $MNT if [ -e "$DEST/$filename" ]; then echo >&2 ERROR: Won\'t clobber other Kindle notes elif mv --no-clobber \ "$MNT/documents/My Clippings.txt" \ "$DEST/$filename"; then #chown "$USER:$group" "$DEST/$filename" # remove the supporting file only if the clippings were moved successfully rm -rf "$MNT/documents/My Clippings.sdr" else echo >&2 ERROR: Couldn\'t move the clippings file: maybe you need to mount \in Thunar fi # sudo umount $kindle