I'm trying to create an array and use Homebrew to install apps. But before I install the app I want to check to see if it's installed. I know it's already there in Brew, but I was looking at something like this:
declare -a applications=(Spotify Discord Franz Rectangle visual-studio-code VLC microsoft-excel)
for i in "${applications[@]}"
do
#check for app installer
if [ -d "/Applications/$i.app" ]; then
echo " $i is installed"
appstatus="Installed"
else
echo "/Applications/$i.app"
appstatus=" $i, not installed - installing now"
brew install cask "$i"
fi
echo $appstatus
done`
However what's happening is the array of applications will always fail on VSC and Excel due to the -'s not being in the name in the application folder.
Either I was going to create another array with the correct names underneath - or I was wondering if I can parse the array and remove the -'s for when we check to see if the app is installed.
Hope this makes sense.