Skip to content

Instantly share code, notes, and snippets.

@dbb
Created July 23, 2011 17:27
Show Gist options
  • Save dbb/1101651 to your computer and use it in GitHub Desktop.
Save dbb/1101651 to your computer and use it in GitHub Desktop.
#!/usr/bin/zsh
out_html="$HOME/sandbox/pics.html"
top_dir="$HOME/sandbox/pics"
gal="$top_dir/gallery"
header="HEADER TEXT"
footer="FOOTER TEXT"
mklnk() {
print '<a href="'"$1"'"><img src="'"$2"'" /></a>' >> $out_html
}
cp $out_html ${out_html}.orig
print $header > $out_html
arr=( ${(f)"$(find $gal -name '*_th.*')"} )
for i in $arr ; do
full=$(print $i | sed 's/_th//')
mklnk $full $i
done
print $footer >> $out_html
cat $out_html
# ls -r pics
# pics:
#gallery pics.html thumbs
#
#pics/gallery:
#a b
#
#pics/gallery/a:
#pic1.png pic1_th.png
#
#pics/gallery/b:
#pic2.png pic2_th.png
#
#pics/thumbs:
#thumb1.png thumb2.png thumb3.png
# cat pics.html
#HEADER TEXT
#<a href="/home/dbb/sandbox/pics/gallery/b/pic2.png"><img src="/home/dbb/sandbox/pics/gallery/b/pic2_th.png" /></a>
#<a href="/home/dbb/sandbox/pics/gallery/a/pic1.png"><img src="/home/dbb/sandbox/pics/gallery/a/pic1_th.png" /></a>
#FOOTER TEXT
@dbb
Copy link
Author

dbb commented Jul 23, 2011

#!/usr/bin/zsh

gal="$HOME/sandbox/pics/gallery"
thumb_dir="$HOME/sandbox/pics/thumbs"

thumbs=( ${(f)"$(find $thumb_dir -name '*.png*')"} )

for i in $thumbs; do
    rename 's/\.png/_th.png/' $i
done

cp -ir ${thumb_dir}/* $gal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment