1 Reply
      Latest reply on Oct 9, 2016 7:41 AM by eskimo
      balistrerin Level 1 Level 1 (0 points)

        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) contains "10.12") then
          do shell script (" rm  -rf \"Step 1 Installer.mpkg\" ")
          do shell script (" rm -rf  \"Step 1 Installer (SIERRA ONLY).mpkg\" ")
          end if
        end tell
        • Re: Applescript remove folder from directory with special characters and spaces
          eskimo Apple Staff Apple Staff (13,325 points)

          Two things:

          • The snippet you posted uses relative paths.  Last I checked AppleScript doesn’t guarantee the current working directory when it runs a script, so it’s best to deal with absolute paths.  If you want to get well-known locations, use path to.

          • When passing paths to AppleScript’s do shell script, it’s important to use quoted form of.

          To put these two together, here’s how to call stat on an arbitrary item on the desktop.

          set itemName to …
          set desktopPath to POSIX path of (path to desktop)
          set itemPath to desktopPath & itemName
          do shell script "stat " & quoted form of itemPath

          ps Technote 2065 do shell script in AppleScript has a bunch of useful hints in this space.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"