Picasa

From Attie's Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "==Extract a copy of all of the starred photos== <source lang="bash"> #!/bin/bash DEST=~/starred_photos SRC=. if [ -e "${DEST}" ]; then echo "${DEST} already exists!" ech...")
 
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 "${DEST} already exists!"
  echo -n "continuing in 3..."
+
echo -n "continuing in 3..."
  sleep 1
+
sleep 1
  echo -en "\rcontinuing in 2..."
+
echo -en "\rcontinuing in 2..."
  sleep 1
+
sleep 1
  echo -en "\rcontinuing in 1..."
+
echo -en "\rcontinuing in 1..."
  sleep 1
+
sleep 1
  echo -en "\r                  \r"
+
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}")
+
I=$(dirname "${i}")
  cat "${i}" | \
+
cat "${i}" | \
    dos2unix | \
+
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}}' | \
+
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
+
while read i; do
      s=${I}/${i}
+
s=${I}/${i}
      S=$(dirname "${s}")
+
S=$(dirname "${s}")
      d="${DEST}/$(echo "${s}" | cut -b 3-)"
+
d="${DEST}/$(echo "${s}" | cut -b 3-)"
      D=$(dirname "${d}")
+
D=$(dirname "${d}")
  
      if [ ! -e "${D}" ]; then
+
if [ ! -e "${D}" ]; then
        mkdir -p "${D}"
+
mkdir -p "${D}"
      elif [ ! -d "${D}" ]; then
+
elif [ ! -d "${D}" ]; then
        echo "'${D}' is not a directory..."
+
echo "'${D}' is not a directory..."
        break
+
break
      fi
+
fi
  
      if [ "${d}" != "$(readlink -f "${d}")" ]; then
+
if [ "${d}" != "$(readlink -f "${d}")" ]; then
        echo "ERROR... readlink mismatch"
+
echo "ERROR... readlink mismatch"
        exit 1
+
exit 1
      fi
+
fi
  
      echo "${s}"
+
if [ ! -e "${d}" ]; then
      if [ ! -e "${d}" ]; then
+
echo "Copy: '${s}'"
        cp "${s}" "${d}"
+
cp "${s}" "${d}"
      fi
+
else
    done
+
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>

Revision as of 20:05, 3 August 2014

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
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox