Monday, January 28, 2019

Spotlight and File Full Path

I remember that long time ago, I can use Spotlight to make a copy of file/folder's full path, just by pressing cmd+c keys if the text is a file/folder. However, this feature seems not working in resent macOS anymore (High Sierra or Mojave).

Even though, I realize that the spotlight can still reveal full path when cmd key is pressed. This feature is available in High Sierra or Mojave. As seen in the following snapshot.



By the way, above screen shot was hard to make(any screen shootout keys will make the path disappeared). I had to record the section screen first and then to take snapshot from the recorded video.

One interesting thing is that I found a way to get full path! By chance I accidentally pasted my clipboard in Safari's address bar one day. I got the full path. As show in the following snapshot:



That's very interesting finding. There are more places I can get full path. Safari's search bar, Notes app search bar. However, it is not working in Terminal app directly, nor in Finder's search bar. I think Finder's search bar is actually a spotlight.

Anyway, I could not find this solution in web. Maybe this is a undocumented trick in macOS. In this way, file/folder's full path can be obtained indirectly from some app's bars. From there, the path text can be copied as text when it is selected, as for the above example:

/System/Library/CoreServices/Applications/Screen Sharing.app

UPDATE: recently I updated my Mac to macOS Catalina. Unfortunately this feature is not available in this new OS. I could not paste a copy I made in Finder for a file or folder item to Safari's address bar as a full path string.

However, the full path can be obtained in Terminal by cmd+v paste!

Another finding is to jump to a file's location in Finder from Spotlight. For example, type something like "iTunes" in Spotlight. You will see the first item in result list is iTunes - Applications.


Hold Cmd key and double click on this item. You will jump to the file in Finder. From there you can make a copy



and paste it to Terminal to get its full path.


Saturday, November 3, 2018

Clean Installation of macOS Mojave

I have MacBook Air-13 Early 2014 model. I did update to Mojave on Oct 22, after downloading the OS from App Store. The update was very straightforward. However, after several days my Mac lost Internet connection. It was really frustrating with no connections to outside.

The following is my story of how to get my Mac Mojave back to normal.

Back to Previous OS


Fortunately I had TM backup before my update. I restored my Mac to previous OS High Sierra as first step. Then I repeated updating to Mojave again. This time before rebooting, I stoped the update process (force to kill the update process from Apple icon->Force Quit).

I remember that I made bootable USB disk before. I decided to boot from another bootable USB to make a clean installation. I followed the advice from an article to make a bootable OS USB as in references. Actually I think this step may not be required. It may be good to make one for emergency or installation to other Macs easier.

Clean Installation


The next step is to reboot. While it is rebooting, hold on cmd+R keys till you see Apple logo. After seconds, a menu of options is displayed. Choose "Disk Utility" to erase my Mac HD. This will guaranty an installation to a clean Mac. Create an admin user during installation.

Migration Assistant


When it is done, login to admin and run Migration Assistant. This app provides options to migrate accounts, Applications, and documents back from TM. In the option list, uncheck Computer and Network settings.

With above steps, now my Mac is back alive, and all my apps, accounts and documents to a new Mojave. So far so good. I hope this clean installation will be fine.

By the way, I went to local Apple Store to get advice yesterday. I explained my situation and strategy of a clean installation, and they agreed this way. Since the process took very long time: back up to TM again with latest documents(specially my Xcode source codes), installation, and lastly migration, I had to go home to finish the whole process. During this process, I got Apple Support call twice to confirm my restoration fine. Even though Mojave release is really not a solid package, I had to thank Apple support stuff for their effort and help.

References


Tuesday, April 17, 2018

Remove Folder/File by Using Terminal

Normally, you can remove files/folders from Finder just by selecting files/folders first and then hitting "delete" key. However, I encountered a special case that I could not remove a folder in Finder. I got a prompt message saying that the folder is in use. Actually this is a misleading message. The folder is not in use and I could not delete it even after I tried to restart my mac.

Further investigation, I found that the folder is in kind of nested loop endless. It is in my Trash. I don't know why it is like that.



Full Path to the Folder


The first thing I need is to find the path to the folder. The file/folder full path is not obviously available in Finder.

There is a way to obtain the full path from folder's Info. Just locate the folder in Finder, and hit Command+i combination keys. This will bring up an info window.

For example, the following is the info window for the folder in my Trash.




Highlight Where section, kit Command+c keys to make a copy. This will copy the full path of the folder to clipboard, ready for use.

Terminal to Rescue

Use spotlight to open Terminal. This can be easy done by pressing Command+space keys, and type in terminal in spotlight search area. Press enter key to open Terminal.

I remember that there is a command tool to remove folders. It is the command of rm.

First I have change current location to the path where the folder is. Use the following command cd to change the current location or directory or path:

  1. cd /Users/dchu/.Trash

Before removing the folder, I have to make sure the folder is there. Use ls command to show the content of the current directory, with -F switch to show folder:

  1. ls -F
  2. iPhoneDev copy 6.00.02 PM/

Now it is time to remove the folder. Use rm command with -R switch. This switch will force to remove the folder as well as any contents, such as files and folders, within the folder.

  1. rm -F iPhoneDev\ copy\ 6.00.02\ PM/
Tip: when you type in folder's name, you can just type in a few characters like "iPho" first, and press tab key to get the complete name filled out.

Kit enter key and the folder is gone!

Note: there may be spaces within file or folder names. The spaces in a file or folder name can be specified by escape char \, just like above example.

References





Friday, April 13, 2018

Update to macOS High Sierra

It is late time to get my macOS updated to High Sierra. I had to to do this when my iOS phone was updated to iOS 11.3. I could not run my Xcode project from my mac to my iPhone with the new iOS. I quickly found out the reason I have to update my mac to High Sierra.

Anyway, the update is very smooth. It is a long process of about 40 minutes. I did late in the night and saw the update completed early in the morning.

Here is the space difference before and after the update.

Before:



After:



It is not surprise that I get more space after the update. Nice job, Apple!

Sunday, September 10, 2017

Do you know your sleep patten?

If you ask me this question several weeks ago, I would shrug and could not tell you anything. Normally I would go to bed when I feel really exhausted. I have no problems to sleep and would go all the way to the next morning or the time I have to go to washroom. However, my sleep may be interrupted by some sudden events or some thoughts causing me awake hardly back to sleep. If this kind of things happen more, it may indicate my health status in downhill.

I know that sleep is very important in terms of health. With mobile technology in past years, I notice that many mobile device or sensors could tracing sleep pattern. However, I have been very hesitate to purchase one just for monitoring my sleep pattern.

Until recently, an icon in Clock app caught my attention. There is a new icon in the tool bar in the Clock app. The icon is a bed. Soon I found out this is called as BedTime, something related to sleep. After my initial investigating, I really love this simple and elegant app.

How to open BedTime

Normally I open Clock from Control Centre, swapping from bottom up. Clock is one of most commonly used apps, finding world time and setting up alarm.



The BedTime is right in the middle of bottom tool bar.


The first time open this app, you will go through several steps to set it up. I think you don't need to bother about details of each setting, just accept the default settings. You will be able to change those settings when you know how to use it. Here is the main screen of BedTime.


The Options on the top left corner is the place you can change settings.

Use BedTime

The interface of BedTime is very simple. The yellow circle arc indicates sleep time, one end as to bed time and another as up time or alarm time. You can tap on either end and drag to a time as your wish. The number in the middle shows the duration of bed time.

If you want to keep certain number bed time time, for example 8 hours, you can set up both ends first, and then drag the yellow circle to adjust both to bed time and up time with bed time unchanged.

After your setup, you may get a notification before bed time, 15 minutes as default. At up time, alarm will wake you up. I find out this is really good replacement of alarm.



You can tap on Stop or open your iPhone with a tap on Home or on Stop button.

Note: there is a separate volume control for alarm in BedTime's Options.

Tips and Tricks

You can enable/disable Bedtime time on certain days within a week. There is only one setting for bed time and up time. You cannot set different times for difference days within a week. Fortunately, I know well about when I should be up the next day. So I set up my bed time and up time every day to guaranty my sleep time. I think it is good to set up bed time every day so I keep more attention to my sleep.

As iOS ecosystem, BedTime is integrated with Health app. All the history bedtimes are saved to Health Sleep section.




From Health, you will see more detail about your sleep data, as well as deleting and adding data.

One interesting thing about BedTime is that this app is smart enough to know when you are awake. If you touch your iPhone during bedtime to open it, that active moment is marked as one end of bedtime, and the next inactive moment would be marked as another in-bed time. This is really good if you have to get up do something, for example washroom. You will be able to see your sleep pattern in more detail in Health Sleep section.




If you manually add sleep time from Health, you will set three types of sleep data.



Notice that the time from BedTime saved to Health Sleep section is "In bed". There are other two times: Asleep and Awake. Indeed, there is no connection to any sensors in BedTime can tell if you are in asleep. This app is a simple one to let user to set up bed time and up time. Therefore, it will be up to user to make accurate adjustment in order to trace user's sleep pattern.

After weeks use, I really like this new feature in Clock. At least there is a way to let me know my sleep pattern, at least very close to (actually it records in bed time). BedTime also let me know if I have enough sleep time so that it would motive me to pursue a heathy life style.

Thursday, April 13, 2017

Get Media from iOS Devices to Mac

There are many ways to get photos or movies from iOS device to Mac. For example, using Photos, iMovie or iTunes apps. However, those methods would place media into app's libraries. Sometimes, I may use another Mac or friends Macs where I don't want to save my media.

Here I recommend two methods to do that.

Image Capture


Image Capture is an app come with Mac. You can easily find it from Spotlight.



In order to get media files from iOS device, you need to connect your device to the Mac. Then you will be able to see media files on your devices in Image Capture. The neat thing about this app is that you can also import media files from any other devices, such as camera, Android device, or USB hd.

AirDrop


This method is so convenient that you don't need to a wire to connect your iOS devices to Mac. In order for your Mac to accept files from your iOS devices, you have to set up your iOS Airdrop to Everyone. This can be done easily from iOS mission control panel.

Open your Finder and select AirDrop on left panel. This will make your Mac ready, as an AirDrop point, for iOS to share.

Then you can open your Photo app on iOS. Select photos and movies.  Tap on share button. Finally, select your Mac icon to send files. All shared files will be saved into your Download folder on Mac.

The only restriction is that this method is available to iOS devices.

By the way, AirDrop is also the best way to share media between iOS devices. You will be able to get original media with timestamp, location and other meta data.

Using Automation for Different Text-to-Speechs

I like Mac's Text-to-speech feature very much. Within System Preferences, you can set up a default voice for this feature in Dictation & Speech. Then you can select a text anywhere, for example in Safary, and you can let Mac to read text for you. Since Mountain Lion, Mac OS X provides support for Chinese. I like this feature very much.

However, it is so inconvenient to make changes if I switch between English and Chinese. I want to find out a simple way to change default voice, for example, from Alex to Ting-Ting.

Finally I found a solution. It is actually very easy. Here are steps.

Create A Service by Automator


First, launch Automator from Spotlight. Select service.

In the right panel, add two items to workflow: Service receives selected text, and Speak Text.


Repeat the same steps to create another one with Ting-Ting as voice.

Speak Text by Your Service


After you create above services from Automator, it is ready to let Mac to read text for you. First, you select a selection of English text. Then right click on the selection to bring up context menu. Click on Services and find out your service. For example SpeechByAlex.