Picasa
From Attie's Wiki
(Difference between revisions)
m (→Extract a copy of all of the starred photos) |
m (→Extract a copy of all of the starred photos) |
||
Line 7: | Line 7: | ||
if [ -e "${DEST}" ]; then | if [ -e "${DEST}" ]; then | ||
− | + | echo "${DEST} already exists!" | |
− | + | echo -n "continuing in 3..." | |
− | + | sleep 1 | |
− | + | echo -en "\rcontinuing in 2..." | |
− | + | sleep 1 | |
− | + | echo -en "\rcontinuing in 1..." | |
− | + | sleep 1 | |
− | + | echo -en "\r \r" | |
fi | fi | ||
mkdir -p "${DEST}" | mkdir -p "${DEST}" | ||
Line 20: | Line 20: | ||
find . -name '.picasa.ini' | \ | find . -name '.picasa.ini' | \ | ||
while read i; do | while read i; do | ||
− | + | I=$(dirname "${i}") | |
− | + | cat "${i}" | \ | |
− | + | dos2unix | \ | |
− | + | awk 'BEGIN{k=0;f=""}{if(substr($0,0,1)=="["){f=substr($0,2,length($0)-2)}else if($0=="star=yes"){print f}}' | \ | |
− | + | while read i; do | |
− | + | s=${I}/${i} | |
− | + | S=$(dirname "${s}") | |
− | + | d="${DEST}/$(echo "${s}" | cut -b 3-)" | |
− | + | D=$(dirname "${d}") | |
− | + | if [ ! -e "${D}" ]; then | |
− | + | mkdir -p "${D}" | |
− | + | elif [ ! -d "${D}" ]; then | |
− | + | echo "'${D}' is not a directory..." | |
− | + | break | |
− | + | fi | |
− | + | if [ "${d}" != "$(readlink -f "${d}")" ]; then | |
− | + | echo "ERROR... readlink mismatch" | |
− | + | exit 1 | |
− | + | fi | |
− | + | if [ ! -e "${d}" ]; then | |
− | + | echo "Copy: '${s}'" | |
− | + | cp "${s}" "${d}" | |
− | + | else | |
− | + | SS=$(cat "${s}" | sha256sum -b -) | |
− | + | SD=$(cat "${d}" | sha256sum -b -) | |
− | + | if [ "${SS}" != "${SD}" ]; then | |
− | + | echo "Copy: '${s}' (checksum mismatch)" | |
− | + | cp "${s}" "${d}" | |
− | + | fi | |
− | + | fi | |
− | + | done | |
done | done | ||
</source> | </source> |
Latest revision as of 20:05, 3 August 2014
[edit] Extract a copy of all of the starred photos
#!/bin/bash DEST=~/starred_photos SRC=. if [ -e "${DEST}" ]; then echo "${DEST} already exists!" echo -n "continuing in 3..." sleep 1 echo -en "\rcontinuing in 2..." sleep 1 echo -en "\rcontinuing in 1..." sleep 1 echo -en "\r \r" fi mkdir -p "${DEST}" cd "${SRC}" find . -name '.picasa.ini' | \ while read i; do I=$(dirname "${i}") cat "${i}" | \ dos2unix | \ awk 'BEGIN{k=0;f=""}{if(substr($0,0,1)=="["){f=substr($0,2,length($0)-2)}else if($0=="star=yes"){print f}}' | \ while read i; do s=${I}/${i} S=$(dirname "${s}") d="${DEST}/$(echo "${s}" | cut -b 3-)" D=$(dirname "${d}") if [ ! -e "${D}" ]; then mkdir -p "${D}" elif [ ! -d "${D}" ]; then echo "'${D}' is not a directory..." break fi if [ "${d}" != "$(readlink -f "${d}")" ]; then echo "ERROR... readlink mismatch" exit 1 fi if [ ! -e "${d}" ]; then echo "Copy: '${s}'" cp "${s}" "${d}" else SS=$(cat "${s}" | sha256sum -b -) SD=$(cat "${d}" | sha256sum -b -) if [ "${SS}" != "${SD}" ]; then echo "Copy: '${s}' (checksum mismatch)" cp "${s}" "${d}" fi fi done done