I've edited the script to create a structure that works with the iPhone 4.0.1 simulator. On my system I have subfolders for iphone simulator 3.2, 4.0 and 4.0.1. So I've kept the original output of the script and modified the structure as it needs to create a PhotoData folder for the thumbnails. After running the script I create sym links for the 3.2 4.0 and 4.0.1 simulator directories as follows:
ln -s $HOME/Library/Application\ Support/iPhone\ Simulator/User/Media/DCIM/ $HOME/Library/Application\ Support/iPhone\ Simulator/4.0.1/Media/DCIM
ln -s $HOME/Library/Application\ Support/iPhone\ Simulator/User/Media/PhotoData/ $HOME/Library/Application\ Support/iPhone\ Simulator/4.0.1/Media/PhotoData
future runs of the script will update all simulators. Here's the modified script:
#!/bin/bash
rootPath="$HOME/Library/Application Support/iPhone Simulator/User/Media"
relPath="100APPLE"
simPath="$rootPath/DCIM/$relPath"
thmPath="$rootPath/PhotoData/$relPath"
if [ -z "$1" ]; then
echo usage: $0 "<folder>"
exit 1
fi
if [ ! -d "$simPath" ]; then
mkdir -p "$simPath"
mkdir -p "$thmPath"
fi
echo "Finding pictures..."
# Find out which incremential number we're at currently.
index=1
for i in `ls $1/*.{JPG,jpg,png,gif,bmp} 2>/dev/null`; do
echo "considering $i..."
while [ -f "$simPath/`printf IMG_%04d.JPG $index`" ]; do
let index=$index+1
done
jpgName=`printf IMG_%04d.JPG $index`
thmName=`printf IMG_%04d.THM $index`
echo $i "->" $simPath/$jpgName
echo $i "->" $thmPath/$thmName
sips -s format jpeg $i --out "$simPath/$jpgName" > /dev/null 2> /dev/null || continue
sips -s format jpeg -z 96 96 $i --out "$thmPath/$thmName" > /dev/null 2> /dev/null || continue
let index=$index+1
done