I think I solved it. Not terrible, but figuring out how to have the shell not split the the paths took me a while. The rest was fairly easy.
I'm posting it down below. Does anyone see anything that will cause me grief? I've tested it a few times and it seems to work and isn't deleting anything like / so far. Any sanity checks that would be smart?
PHP Code:
#!/bin/sh
# adobecleanup4.sh
#
#
# Created by Aaron Robinson on 1/19/12.
# Copyright 2012 __MyCompanyName__. All rights reserved.
#Need to stop shell from interpreting spaces as separators
IFS='
'
#What CS vsersion do we want to search for. Use CS3 CS4 CS5 CS5.1, etc
searchstring="CS6"
currentTime=$(date +%H%M%S)
#Find all $searchstring folders within /Applicatons
for path in $(/usr/bin/find /Applications -maxdepth 1 -name "*${searchstring}"); do
folderpath=${path}
appname=`/bin/echo "${path}" | cut -d'/' -f3`
plistpath=${path}"/"${appname}".app/Contents/Info.plist"
#echo "Base folder path is "$path
#echo "Application name is "$appname
#echo "Plist path is $plistpath"
if [ ! -e ${plistpath} ]; then
if [[ ${folderpath} =~ 'Adobe' ]]; then
#echo "DELETE: $plistpath does not exist"
#echo "Deleting $folderpath"
echo Removing ${folderpath} >> /tmp/adobecleanup_${date}.txt
/bin/rm -Rf ${folderpath}
fi
else
/bin/echo "LEAVE: "${plistpath}" exists"
fi
done
unset IFS
exit 0