How to Determine Mac OS version from Command Line

There are a few ways to determine what version of OSX you are on.

In the GUI, you can click the on Apple menu () at the top left of your screen, and choose About This Mac. The version of OS X will be printed underneath the large bold Mac OS X title. Clicking on the Version XYZ text will reveal the Build number.

If you’re writing a script though, you may wish to access this programmatically. To do this, type:

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.12.6 (16G29)
      Kernel Version: Darwin 16.7.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Srini’s MacBook Pro
      User Name: Srini Karlekar (skarlekar)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 21 days 8:30

$

Resetting the System Management Controller (SMC) on your Mac

Sometimes my Mac Book Retina Pro’s fan goes on high for no apparent reason. I checked the memory and CPU usage and I cannot find a good reason for the increased RPM of the system fan inspite of adequate ventilation.

Apple has this to say about this issue, “It is possible that the SMC could encounter an issue that may cause unusual system behavior typically related to the symptoms described below. In some cases, resetting the SMC may be the only correct method to resolve the issue”.

Apparently, the only way to solve this is as follows, which to my surprise I found it works.

  1. Shut down the computer.
  2. Plug in the MagSafe power adapter to a power source, connecting it to the Mac if its not already connected.
  3. On the built-in keyboard, press the (left side) Shift-Control-Option keys and the power button at the same time.
  4. Release all the keys and the power button at the same time.
  5. Press the power button to turn on the computer.  
    Note
    : The LED on the MagSafe power adapter may change states or temporarily turn off when you reset the SMC.

 

Renaming a file on Mac

Renaming a file on a Mac is not so obvious; plus an Automator script to rename files.

mac-rename

One would think that renaming a file on Mac must be easy given the user-friendliness of Mac OS. Turns out, it is not so obvious.

To rename a file in Finder, you click on the icon preceding the file name once and then click on the file name again. This will highlight the file minus the extension. Now you can type the new name to rename.

Having said that, I was able to create a Automator script that will pop-up a dialog to rename either part of the file (base or extension) by right-clicking and selecting the Services option.

Following is the snapshot of the Automator script.

Automator Script