Applescript remove folder from directory with special characters/space

I have run into some installation problems with the new Sierra update.
I want to run a script that checks the version number and deletes a certain .mpkg file based on the version number because I am having a lot of customers running the wrong installation which is causing a lot of issues. I have tried multiple versions of this code and nothing seems to be working. My result in Applescript console is: “”.
Any help would be greatly appreciated.


tell application "Finder"

    set os_version to do shell script "sw_vers -productVersion"

    if ((os_version as string) is equal to "10.12") then

    do shell script (" rm  -rf \"Step 1 Installer.mpkg\" ")

else

    do shell script (" rm -rf  \"Step 1 Installer (SIERRA ONLY).mpkg\" ")

end if

end tell


You can’t use do shell script inside a Finder tell block. In any event, you don’t actually have the Finder doing anything.

Try something like this:

tell application "Finder"
	set finder_version to version
end tell
if finder_version begins with "10.12" then
	do shell script (" rm -rf  \"Step 1 Installer (SIERRA ONLY).mpkg\" ")
else
	do shell script (" rm  -rf  \"Step 1 Installer.mpkg\" ")
end if

Just for the record, the minor version of the Finder doesn’t always match the Mac OS X version, only the major version number.

Yes, it’s probably a bad idea – but it does hold for Sierra, which this code looks hard-coded for.

Perhaps we should direct the OP here:

macscripter.net/viewtopic.php?id=43167