annotate tools/anti_bins @ 3:66beb7e16b22

Added tag 1.1.29-extended for changeset c44d020e5f8a
author Peter Gervai <grin@grin.hu>
date Wed, 15 Oct 2008 23:32:04 +0200
parents a84c32f131df
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
1 #!/bin/sh
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
2
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
3 # This program creates a image files tree for each image size from a BINS album.
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
4 # Edit the variables in the configuration section and run it.
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
5
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
6 # (c) 2003 J?r?me SAUTRET <jerome@sautret.org>
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
7 # This script is distributed under GNU GPL. Ask Stallman for details.
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
8
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
9 # $Id: anti_bins,v 1.1 2004/05/08 20:02:39 jerome Exp $
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
10
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
11 set -o nounset
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
12
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
13 ####################################################################
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
14 # Configuration section
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
15
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
16 ALBUM="Album"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
17
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
18 # Path of the HTML album directory
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
19 HTML_ALBUM="$HOME/Photos/$ALBUM/html"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
20 # Path of the destination images directory
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
21 IMAGE_ALBUM="$HOME/Photos/$ALBUM/Images"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
22
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
23 # size names in the image file,
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
24 # followed by the names of the directories that will be created for each picture sizes
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
25 # separated by a colon
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
26 IMAGE_SIZES="Sm:Small Images,Med:Medium Images,Lg:Large Images"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
27 #IMAGE_SIZES="Pt:Petites images,Moy:Images moyennes,Gd:Grandes images"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
28
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
29 # Copy command
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
30 COPY="ln -f" # use this to create hard links, works only if source & dest are on same partition
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
31 #COPY="ln -sf" # use this to create symbolic links
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
32 #COPY="cp -f" # use this to copy images
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
33
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
34 # Image extensions
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
35 IMAGE_TYPES="jpg|png"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
36
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
37 # Set this to 1 when configuration is done.
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
38 CONFIGURATION_IS_OK=0
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
39
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
40 # End of configuration section
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
41 #####################################################################
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
42
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
43 ls --ignore-backups --file-type >/dev/null 2>/dev/null
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
44 if [ $? != 0 ] ; then
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
45 echo "This program runs only with a 'ls' supporting the '--file-type' option"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
46 echo "Install GNU ls or send me a patch..."
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
47 exit 2
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
48 fi
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
49
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
50 if [[ $CONFIGURATION_IS_OK == 0 ]] ; then
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
51 echo "Edit this script to set configuration variables."
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
52 exit 1
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
53 fi
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
54
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
55 IMAGE_SIZES="$IMAGE_SIZES,"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
56 SIZES="`echo "$IMAGE_SIZES" | sed "s/\([^:]*\):[^,]*,/\1 /g"`"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
57
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
58 size_name()
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
59 {
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
60 echo "$IMAGE_SIZES" | sed "s/^.*$1:\([^,]*\),.*$/\1/"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
61 }
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
62
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
63 copy_dir()
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
64 {
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
65 local SOURCE DEST F
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
66 SOURCE="$1"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
67 DEST="$2"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
68
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
69 echo "Traitement du r?pertoire $1"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
70
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
71 cd "$SOURCE"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
72 for SIZE in $SIZES
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
73 do
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
74 SIZE_NAME="`size_name $SIZE`"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
75 mkdir -p "$IMAGE_ALBUM/$SIZE_NAME/$DEST" >/dev/null
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
76 for F in `ls --ignore-backups|grep -E "_$SIZE.($IMAGE_TYPES)$"`
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
77 do
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
78 DEST_FILE="`echo "$F" | sed "s/_$SIZE\\././"`"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
79 DEST_FILE="$IMAGE_ALBUM/$SIZE_NAME/$DEST$DEST_FILE"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
80 if [ ! -f "$DEST_FILE" ] ; then
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
81 echo "copie de" "$SOURCE$F" vers "$DEST_FILE"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
82 $COPY "$SOURCE$F" "$DEST_FILE"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
83 fi
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
84 done
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
85 done
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
86 for F in `ls --ignore-backups --file-type | grep "/$"`
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
87 do
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
88 # Decode URL
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
89 DEST_DIR="`echo "$F"|sed 's/%\([A-F0-9][A-F0-9]\)/\\\\x\\1/g'`"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
90 DEST_DIR="`printf "$DEST_DIR"`"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
91 # _ to spaces
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
92 DEST_DIR=`echo "$DEST_DIR"|sed 's/_/ /g'`
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
93 copy_dir "$SOURCE$F" "$DEST$DEST_DIR"
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
94 done
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
95 # Remove dir if empty
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
96 rmdir "$IMAGE_ALBUM/"*"/$DEST" 2>/dev/null
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
97 }
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
98
a84c32f131df Import vendor version
Peter Gervai <grin@grin.hu>
parents:
diff changeset
99 copy_dir "$HTML_ALBUM/" ./