#!/bin/sh # Useful if you have a directory of images which you use # for a rotating desktop picture on Mac OS X. When run # this script will print out the name of the image # # The DIR is set twice as it has a space in it and the # first command won't really find it properly. DIR=`defaults read com.apple.desktop Background | grep ChangePath | grep -v NewChangePath | tail -n1 | cut -d"=" -f2 | tr '";' ' ' | tr -s ' ' | cut -d" " -f3-` DIR="$HOME/Pictures/Desktop Pictures" IMG=`defaults read com.apple.desktop Background | grep LastName | tail -n1 | cut -d"=" -f2 | tr '";' ' ' | cut -d" " -f3` echo "Current Desktop Picture: $IMG" if [ "$1" = "-rm" ]; then echo "Are you sure you want to delete $IMG [y/N]: \c" read result if [ "x$result" = "xy" -o "x$result" = "xY" ]; then rm "${DIR}/${IMG}" echo "Background $IMG deleted" else echo "Background $IMG has not been deleted" fi fi