I need to look for four folders that should have been automatically added to each user's Documents folder. I wrote a simple script that should check if the folders exist. If they don't, it will run the Jamf policy that creates them. The problem I keep running into is that when I test the script, the results tell me that the folders exist even when they don't. Obviously I'm doing something wrong but I can't figure out what. Please help! The script is below. If I manually type a command the commands in Terminal, I can get an accurate response. The script tells me that the folders are present whether they are or not. What the heck am I doing wrong?
#!/bin/sh
###Looks for PDF folders in a user's Documents folder. If the folders are not present this script will run the Jamf policy that creates them.
currentuser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
echo $currentuser
pdfFolders=$(
/Users/$currentuser/Documents/"PDFs for Client Reports"
/Users/$currentuser/Documents/"PDFs for ATBs"
/Users/$currentuser/Documents/"PDFs for Estimates"
/Users/$currentuser/Documents/"PDFs for Insertion Orders"
)
if [ -d $pdfFolders ]
then echo "Folders present"
else echo "Folders not present"; jamf policy -event install-fmfolders
fi
