Category Archives: macOS

How to remove files from ZIP Archives in macOS and Linux

When ZIP up directories, particularly on macOS, some files may find their way into our ZIP archives that were never meant to be there. I’m thinking of those pesky .DS_Store and __MACOSX files, maybe even .htaccess files. For *nix based systems, * really means “everything”.

The ZIP command line tool let us remove such unwanted files from an existing archive. Here’s how:

The -d switch tells ZIP to hunt for and delete the unwanted files. Files whose names contain spaces can be defined in “regular quotes”, and the * asterisk can be used as usual.

For example, to remove all DS_Store files and __MACOSX files, we can use this:

To verify that such idiosyncrasies have indeed been removed from a ZIP archive before we release it into the wide, we can check with the UNZIP utility:

This will simply list the contents of your-archive.zip without actually extracting it.

How to add files to an existing ZIP Archive on macOS and Linux

Sometimes it’s easy to delete a ZIP file and create a new one – say you’ve forgotten to include a file. Just drag it into the folder to be ZIPped up and start again.

However, the clever little ZIP command line tool has a built-in ability to simply add a file to an existing archive without us having to do any manual grunt work. That can come in handy when we no longer have access to existing unZIPped content.

Here’s how it works:

We can even add entire directories this way too, like so:

This will recursively add all files (indulging hidden and annoying ones) to our file.

Note that ZIP accomplishes this by temporarily extracting all files before creating a new archive for is (while deleting our original file). So in essence, the tools is doing what we’d do manually, just more conveniently and in the background without bothering us.

How to bring up the Emoji Keyboard on macOS

We all love Emojis, and it’s so super easy to insert them from an iOS keyboard. I do this frequently in messages. It stands to reason that it should be just as simple to do this on laptops and desktop Macs too – but how? Isn’t there some kind of shortcut we can use?

Well yes there is – I just keep forgetting which one it is 😂 so here it is:

CTRL + CMD (OPTION) + SPACE

This handy combination brings up an Emoji Picker. Find the icon you like, click on it, and the dialogue automatically closes again after it inserts your Emoji.

How to fix Spotlight Search stop it from disappearing on macOS

For a while now I’ve seen my poor Spotlight Search disappear on all my Macs disappear after typing only two or three letters. This has never been a problem since I’ve been using macOS. I have 4 systems in total, running Sierra and High Sierra, and all of them exhibit this problem.

However, my wife’s MacBook Air is still running Mavericks and – not having been updated for a while – is NOT experiencing this issue. So what’s going on there?

After some digging, I am not the only user who has an issue with Spotlight Search. Some suggest we all have to re-index Spotlight (which does take a while, multiplied by all the computers you’re using), but they report that the issue will come back sooner or later.

The most efficient way to make Spotlight Search operational again is to simply disable one of the items it’s searching when we use it – namely the Bookmarks and History option.

To access the above menu, head over to the Apple Icon and select System Preferences. From here, either click the Spotlight Logo (top right corner) or search for Spotlight. Un-tick the second box from the top, close the dialogue and – voila – Spotlight is working again!!

This thread on the Apple Forums suggests that the culprit is Safari 12 (I’m using 12.0.1 at the time of writing). Disabling Bookmarks and History means Spotlight is not accessing Safari’s (changed / faulty / updated / whatever) database and seems to work fine as a result.

Worked great for me – I hope it’ll work for you just as well 🙂

How to download older versions of macOS after Mojave was released

My good old MacBook Pro from 2011 can only supports macOS up until 10.13 High Sierra. It’s been purring along nicely with macOS 10.12 Sierra for the last couple of years, and I didn’t see the need to upgrade just yet. Why risk breaking things that are working, right?

A couple of weeks ago, macOS 10.14 Mojave was released, with which my MacBook is sadly no longer compatible (not officially at least). So when I searched for “High Sierra” on the Mac App store, I was surprised to learn that it didn’t come up. It appears that only the very latest macOS release is available to download from the Mac App Store.

So now the $100k question is: How can I get an official copy of macOS High Sierra, now that Mojave is out? I’ve never downloaded it before, therefore it doesn’t show up in my “previous purchases” tab either. Have I missed my 12 month window to download the last operating system that’s compatible with my hardware?

Lucky for us, Apple have made some contingencies. I did some research and found several older Mac operating system for ya’ll’s enjoyment. Might come in handy 😉

Continue reading How to download older versions of macOS after Mojave was released

How to transfer files from your GoPro to your computer via WiFi

There is an iOS and Android App available to transfer files directly from a GoPro camera to a mobile device. Those apps transcode files and compress them for easier viewing, and to save storage space.

While that approach gets footage onto my iPhone, I still need to transfer the files to my Mac for editing. Plus, there’s an additional compression step involved which can’t be good for picture quality. Besides, it takes forever to do its job.

A much more useful approach would be to hook directly into the GoPro and transfer files that way. This leaves the SD card place and doesn’t disturb the (sometimes hard to reach or difficult to recreate) position of the camera.

Here’s how to do it.

Continue reading How to transfer files from your GoPro to your computer via WiFi

How to take pictures with Photo Booth on macOS

In this episode I’ll show you how to take pictures with built-in and external USB cameras using Photo Booth on macOS. Photo Booth is the equivalent of the Camera application in iOS.

I will also explain how to export your images, where they are stored on the hard disk, and what you can do if the built-in camera gives you an error message.

For Ivy-Jo.

Troubleshooting

As I’ve explained in the screencast, if Photo Booth or any other app is giving you grief about there camera “not being available”, you can try to reset the VDCAssistant process on macOS.

To do this, open the Terminal app, then type the following:

Provide your administrator password when prompted, and without a reboot, Photo Booth should be working as it should. Thanks to Turn It Off And On Again for this tip!

Catch this episode on my WP Guru Podcast:

How to turn text into an audio file on macOS

Ever since Lion, Mac OS X 10.7, there has been a great and very underrated feature built-in to every Mac: the ability to highlight some text and have macOS turn it into an audio file.

This is a wonderful way to listen to written text while you’re on the go, or if you want to skim through text you or others have written while you’re occupied with another activity, such as walking or driving. I love this feature!

I’ve seen the option in the context menu many times, but I’ve never dared to use it until today. Perhaps I held off for so long because the option reads “add to iTunes as Spoken Track” – and I’m just not a big fan of iTunes.

Turns out, this text-to-audio option bypasses iTunes altogether. It doesn’t open automatically and we won’t need it to transfer tracks to our iPhones either. What a relief!

Let me show you how to do it in this article. Continue reading How to turn text into an audio file on macOS

How to transcode an AFIC file with macOS Finder

Yesterday I had to transcode some audio files recorded with Quicktime on macOS. Quicktime works great for that, but it only stores files in its native AIFC file format. That’s the Audio Interchange File Format, a format developed by Apple in 1988, storing audio data as uncompressed PCM data.

Sadly though, AIFC is not commonly readable by many applications, and as such the data needs to be transcoded to be used successfully elsewhere. And Quicktime offers that option too, simply by choosing File – Export – Audio Only. This will create an MPEG 4 audio file with the M4A extension.

While that file sounds fine, and its size is only a fraction of what the original AIFC file was, this transcoding process does not allow us to choose which compression algorithm to use upon export. As it turns out, Quicktime introduces a very good, albeit lossy compression when it exports files in this manner.

I wondered if there was a way to extract uncompressed lossless data from the AIFC file, and how to do it. If Quicktime didn’t let me, perhaps there was another way, maybe using some kind of free software tool.

I was glad to find out that I didn’t have to look far: my good friend the Finder has such an option built in! Thanks go to Jim Tanous for sharing his knowledge with us.

All we have to do is open a Finder window, right-click the AIFC file in question, and select Encode Selected Files at the bottom of the context menu. We can even select multiple files and transcode them all at once.

When we do that, a dialogue window comes up. This may take a moment or two, so don’t get nervous if your Mac doesn’t respond instantly to this request (like I did).

Now we get options! We can pick  destination for our new files, and we even get the choice to delete the original AIFC file if we so desire (and if we’re confident enough about this workflow’s capabilities).

The best option we get though is that we can pick how the file(s) are to be transcoded though. While we do not get these options during the Quicktime export process, which appears to use the “High Quality” setting (and probably the same tool under the hood), with Finder we can choose the Apple Lossless codec.

From what I understand, all three options apply a lossy AAC compression in varying degrees, resulting in different file sizes, data rates and of course different levels of quality. The only one that stands out is the Apple Lossless setting, which creates a file still smaller than the AIFC file, but with lossless compression, in M4A format.

The resulting M4A output is readable by a wide range of applications.

Thanks, Finder! I didn’t know you did Audio Encoding so well 🙂

How to run Commodore BASIC as a Scripting Language on macOS

Did you know you can run Commodore BASIC v2 on your Mac and Linux systems as a scripting language? It’s true – thanks to the marvellous efforts of Michael Steil and James Abbatiello. They’ve adapted the original BASIC v2 as featured on the VIC-20 and C64 with additional routines so that it works natively on modern machines. It’s ingenious!

You can get the full source code on GitHub – it works a treat!

For those who don’t quite know what to do with it, here are some instructions that’ll help you get CBM BASIC up and running on macOS.

Download

GitHub provides a convenient way to either clone a repository on your local machine if you have GitHub for Desktop installed, or you can download a ZIP file and unZIP it somewhere on your system. Once done, you should see a directory structure that looks exactly like the repo on GitHub.

Compile

You need a few utilities installed your your Mac to be able to compile files. Downloading Xcode will ptovide you with an excellent (and free) IDE as well as the command line tools needed to do that (gcc, make and several other goodies). You might be able to bring those components in using the Homebrew package manager.

Using your Terminal app, navigate to your unZIPped folder. It includes a MAKEFILE so there’s no need to mess with any parameters. Enter “make” at the command prompt, and after a few moments you should have a file called “cbmbasic” without an extension in the same directory. That’s the binary for your Mac.

To make it executable, we’ll have to tweak the file permissions – otherwise our operating system won’t be able to run it. We’ll do it using the chmod command:

You can test if it works by calling the binary without any parameters like this:

If all goes well you should see something like this:

For easy access, copy the binary over to your /usr/bin directory. That’s where common command line utilities are installed on Mac and Linux systems. The added benefit is that the path to that folder is already in your local $PATH variable, and as such you can simply type “cbmbasic” from any location when you’re on the command line.

Here’s how to copy the binary over (this will ask for your administrator password):

Using Direct Mode

When you run the binary it will bring up something like the standard BASIC command prompt we’re used to seeing on the Commodore 64. There are however a few important differences between a C64 emulator and this implementation:

  • this is NOT an emulator
  • cursor keys DO NOT work
  • all commands typed in must be CAPITALISED

Other than that, you can start typing like on a real machine. Be careful with certain POKE commands though as those may call system routines that might not be implemented.

LOAD and SAVE commands have been tweaked to reference the command line structure. They work just fine, but will load and save files in Commodore file format (which is not clear text ASCII – more on that later). For example:

The above displays the directory of the current folder, much like it was an attached floppy drive. How cool is that? You can reference folders using both LOAD and SAVE just as if you were on the command line.

You can also type in programmes and run them – however the cursor keys won’t work, so there’s no screen editing options. Programmes SAVEd from direct mode cannot be loaded from the command line, only from direct mode (i.e. when launching the binary without parameters).

To quit direct mode, hit CTRL+C.

Running Programmes from the Command Line

The real power of this implementation can be seen when we run files from the command line. Those files must not be SAVEd from direct mode, but instead are simple clear text files. The extension doesn’t matter, but for good practice, let’s store them as .BAS files (much like shell scripts are stored with the.SH extension, or PHP files would be stored with the .PHP extension… you get the idea).

You can write standard BASIC programmes use your favourite text editor (like vi from the command line), or try one from the “test” directory that’s provided with the repository.

Imagine we had a file called “hello.bas” that we’ve created with vi, looking like this:

To run our file, we can simply define it behind the binary like this:

cbmbasic hello.bas

This will greet us with the “Hello World” message on the command line.

Running Script Files

Alternatively, we can specify the full path to cbmbasic at the beginning of a file (she-bang notation) and run it just like any other script file. Observe please:

#!/usr/bin/cbmbasic
10 PRINT “Hello World”
20 PRINT “from CBM BASIC :-)”

If the file was called “hello”, we’d need to change the permissions again so that the file can be executed:

Now we can run it like this:

Sweet – but I can’t work out how to compile this on macOS…

Fear not – I’ve got a macOS binary that was compiled on 10.12 “Sierra”. You can find it in my fork of the project. Check out the “binaries” folder.

Does it work on Windows? Or on Linux?

I’ve tested compiling and running this puppy on CentOS 6 and 7 with roaring success. The above steps worked fine for it, so I’m assuming it’ll work on other Linux flavours just as well (the beauty of portable C code).

According to the author, it works fine on Windows too – however I have no idea how to compile source code on Windows, so you’ll have to figure that out for yourself. I hear good things about Visual Studio  – if I work out how to do it, I’ll add it to the “binaries” folder on my GitHub Fork.

Can I write my own extensions to BASIC?

Apparently so – check our Michael’s site and repo for details:

Right now, if you run SYS 1 from direct mode first, you can use the SYSTEM command (followed by anything you’d like to execute on the command line in “double quotes”) as well as LOCATE (followed by an x and y coordinate to place the text cursor) and WAIT.

Have fun hacking BASIC and letting it run with the blistering speed of modern CPUs 🙂

Watch the full course in one convenient playlist:
Catch this episode on my Commodore Podcast: