10 AppleScripts to make you love your Mac (even more)

Apple's highly useful scripting language is one of the Mac's hidden gems.

1 2 3 4 5 Page 3
Page 3 of 5

Targeted backups

Although Time Machine will do automated backups for those with modern versions of OS X, some readers might want an easy way to, say, keep all files related to a critical project together for an additional "in case of catastrophe" backup, or perhaps for something that could be easily downloaded to a USB drive.

It's pretty intuitive to select files to back up by name or date. For example, take this line of AppleScript:

tell application "Finder" to duplicate (every item in folder "Documents" of home whose modification date comes after (current date) - 7 * days) to folder "backup_docs" of disk "Backups" with replacing

It copies all items in your Documents folder that were modified in the last week to the backup folder on your "Backups" disk; modify the folder locations and dates as needed (note that yesterday would be current date - 1 * days [not day]). "With replacing" tells the script to overwrite any existing files with the same name.

The same "whose" construction can be used to find other things, such as these two statements that can be used for all types of script or image files:

<!--begin code--> whose name contains "script"<!--end code-->

or

<!--begin code--> whose kind ends with "image" <!--end code-->.

Since I prefer to select files to back up based on "everything changed since I last ran this script," here's a quick modification created with Sal Soghoian's help:

Immediate backup on import

This script is designed for tasks like saving photographic images, where (conscientious) users might want to immediately back up files as soon as they're imported. Apple offers a sample script for download, which you set up after you enter source and destination folders; it then continues to run in the background.

I encountered a bit of a performance lag when I played with it, but for some, the security of assured immediate backup is worth a bit of sluggishness.

1 2 3 4 5 Page 3
Page 3 of 5
It’s time to break the ChatGPT habit
Shop Tech Products at Amazon