In this article it helps if you already know a little bit about AppleScript, though that’s not completely necessary. Near the end of the tutorial I show how to invoke the AppleScript code using Scala, so feel free to skip down to there if you just want to see that — you can always read the stuff at the top for reference later.
Mac batch image conversion FAQ: How can I “batch convert” images from one image format to another on a Mac, such as BMP to JPG, or PNG to JPG?
As I mentioned in my earlier Mac batch image resizing tutorial, the Mac OS X Automator application is my new best friend. Besides letting you easily batch resize images very easily, the Automator also lets you easily batch create thumbnails for images, and also lets you convert images from one image format to another (BMP to JPG, PNG to JPG, etc.).
Here’s a quick look at how to use the Mac Automator to “batch convert” images from one file format to another, including image file formats like BMP, GIF, JPEG, and PNG.
In my spare time back in 2011 I created a Java version of the old Unix/X-Windows “Xeyes” application. If you ever used Xeyes, you know it as a set of eyes that are displayed on-screen, and follow the mouse cursor as you move it around.
Now in 2019 I just brought it back to life, and here’s a 56-second video that shows how it works:
Table of Contents
- macOS: crontab, launchd, and launchctl
- Running a simple command every minute with Mac launchd
- 1) Move to the $HOME/Library/LaunchAgents directory
- 2) Create a Mac plist file to describe your job
- 3) Tell MacOS about your Mac plist launchd file
- 4) How Mac launchd works with system reboots
- An important note about root and sudo access
- MacOS launchd, launchctl, and plist resources
- MacOS startup jobs: cron and crontab, launchd and launchctl
MacOS crontab FAQ: How do I run a Unix job (or shell script) through the MacOS crontab facility? I keep trying to edit my Mac crontab file, but my Mac won't save my crontab changes, or run my program.Back to top
macOS: crontab, launchd, and launchctl
Way back when (~2012-2014), I found that the Mac
crontab command was deprecated on MacOS, and the Apple documentation encouraged you to use their launchd facility. Here’s a blurb from Apple's
crontab man page:
“Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands. See launchctl(1) for more information.”
Here’s an example that shows how to find the largest files under a directory on MacOS and Linux/Unix systems.
A du/sort command to show the largest files under a directory on Mac OS X
The Unix/Linux command that worked for me on my MacOS system is this:
$ du -a * | sort -r -n | head -10
du is the disk usage command, and the
-a flag says, “Display an entry for each file in a file hierarchy.” Then I use the
sort command to sort the
du output numerically and in reverse. After that,
head -10 shows only the first ten lines of output. In the Music folder on my Mac the command and output look like this:
If you want to copy the current macOS Terminal path to the clipboard, you can do it with this simple command:
$ pwd | pbcopy
pwd prints the path to STDOUT, and
pbcopy reads that and copies it to the macOS clipboard. Once the path is on the clipboard you can paste it into your other applications.
Of course you can also create an alias, like this:
alias path="pwd | pbcopy"
If you ever need to copy text (or a text file) from the MacOS Terminal to the Mac clipboard, I can confirm that the macOS
pbcopy command works. It reads from STDIN and copies the text to the clipboard, so commands like these work:
$ echo "foo bar baz" | pbcopy $ cat /etc/passwd | pbcopy
As a quick note, I haven’t tried to log into one of my GoDaddy websites in several months, and when I tried to log in just now I got this macOS ssh error message:
Unable to negotiate with <ip-address here> port 22: no matching host key type found. Their offer: ssh-dss
I don’t have much time to explain this today, but ... if you want to see how to use the
sed command on a Mac OS X (macOS) system to search for newline characters in the input pattern and replace them with something else in the replacement pattern, this example might point you in the right direction.