Skip to content

Instantly share code, notes, and snippets.

@mitio
Created April 27, 2011 18:36
Show Gist options
  • Save mitio/944879 to your computer and use it in GitHub Desktop.
Save mitio/944879 to your computer and use it in GitHub Desktop.
Display a folder tree with an image count for each folder containing any .jpg files.
#!/bin/sh
dir="$1"
identation="$2"
self="$0"
if test "$dir" = ""
then
dir="."
fi
# use simple find so that it can work even on BusyBox linuxes
image_count=`find "$dir" -type f -name '*.jpg' -print | grep -v '/.AppleDouble/' | grep -v '/CaptureOne/' | wc -l`
if test $image_count -gt 0
then
echo "$identation$dir: $image_count"
for file in `ls -a -- "$dir"`
do
# BusyBox has a very dump basename, which does not understand the "--" options ending flag
file=`basename "$file"`
path="$dir/$file"
if test -d "$path" -a "$file" != "." -a "$file" != ".." -a "$file" != ".AppleDouble" -a "$file" != "CaptureOne"
then
$self "$path" "$identation "
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment