Adobe application cleanup

I am trying to come up with a universal way of cleaning up after CS5 (and 5.5) installs. The history is this: adobe has a deployment tool called AAMEE that lets you re-package items and deploy them. Unfortunately it's very messy and leaves Application folders (and pieces of the apps) that do not belong.

Here's a more specific example:
Install After effects using package built with AAMEE.

Case 1:
Install After Effects.pkg. (Should only install "/Applications/Adobe After Effects CS5/")

Unfortunately it also adds
"/Applications/Adobe Premier Pro CS5/Adobe Premier Pro CS5.app/" (and a bunch of other app folders, but we will focus on Premier)

The problem is that if Premier was not already installed, the .app bundle is broken. I want to remove the Premier folder and contents from /Applications Simple...remove the directory via a posflight script, unix command, etc. BUT, if only it were that simple.

Case 2:
Install Premier.pkg (AAMEE package)
Install After Effects.ppkg (AAMEE package)

If I fixed this the "easy way", I would have just deleted the desired Premier Pro application. Not my intended effect. This is just one folder example. There are many more (onlocation, soudbooth, etc). So, I started thinking "How do I know which directories are intentional and which ones are unintentional due to AAMEE not being all that smart?"

The only thing I can find is that EVERY that lack lacks info.plist in the app bundle (if the .app bundle even exists) in $appname.app/Contents/Info.plist is bad. If I loop though Applications looking for CS5 folders, then I should be able to figure out which CS5 folders contain working apps.

A working app always has Info.plist which exists in /Applications/"$AppName"\ CS5/"$AppName".app/Contents

It does not exist in"/Applications/Adobe Premiere Pro CS5/Adobe Premiere Pro CS5.app/Contents/" (which was a "bad" install by AAMEE)

If that is true for all unintended of the bad installs, then this should be easy to script. I just can't figure out how. I want to loop through /Applications finding every folder with CS5 in it. Then in each of those folders, check for the existence of $basepath/Contents/Info.Plist. If it's there, then the folder stays. If it's not, then delete the AppFolder from /Applications. I don't want to supply a list of every app. I'd like to find all CS5 folders, work out the path and appname, then loop though each one testing for the existence of $AppPath/Contents/Info.plist. If it doesn't exist, delete the base CS5 folder in /Applications

Some notes:
The App is always named the same as the base folder. (eg. "/Applications/Adobe Illustrator CS5" will always contain the application "Adobe Illustrator CS5.app").
Info.plist is always in $app/Contents/

Anyone interested in helping me solve this?

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?

#!/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