tips and tricks

Create a Password Protected Zip file on Mac OS X

By Jason | Published June 18th, 2011

Will add more information later, but the command is as follows for a directory (the -r means recursive, so it zips all files in the directory preserving the directory structure too):

zip -re filename.zip dir_name

To zip a single file and password protect it just omit the r in -re

Both commands will prompt for a password and to confirm the password.

Recent Applications on OS X Dock

By Jason | Published December 6th, 2010

This came across my RSS feed from Mac.AppStorm and thought it was a very handy stack to have on my Mac OS X Dock, so thought I would share it. To get it to appear just open up a terminal window (go to Spotlight and type in terminal) and copy & paste the following into the terminal window:

defaults write com.apple.dock persistent-others -array-add ‘{ “tile-data” = { “list-type” = 1; }; “tile-type” = “recents-tile”; }’

Copy or Paste within Mac Terminal

By Jason | Published November 29th, 2010

There are two commands that allow you to copy or paste within the Mac OS Terminal application. To copy, say the contents of a file, use the following command:

more filename | pbcopy

To paste the contents of a file use this command:

pbpaste > filename

I find these commands useful when I’m editing a file on my system that I want to be a .htaccess file on a remote server. Since I’m usually connected to the server anyway it is a fast and easy solution so I do not have to open a FTP client.

Useful Automator Scripts for Dealing with Pictures

By Jason | Published February 9th, 2010

The Mac OS X Automator provides simple, but useful, scripting to automate some commonly used functions. For this entry I’m specifically looking at resizing, renaming and replacing characters for pictures to be uploaded to a website.

Initial Script Setup

I like to start off with making the script prompt me for Finder items, allowing selection of a file, folder or multiple selections:

1_ask_for_finder_items

To add the items selected, to the workflow, we use Get Folder Contents:

2_get_folder_contents

The next action, Filter Finder Items, is kind of important. For example, if you received a hundred or so pictures from a client to upload to their website and it came from a PC there more than likely is a .thumb_db file in the folder(s). This would abruptly stop the script from running. To get around this add a Filter Finder Items to the workflow:

3_filter_finder_items

This next step is optional, but is useful if you only have one copy of the images. Personally I just duplicate the folder(s) then delete them. Mainly because I haven’t bothered how to prompt where to copy the original files to, this step just copies them into a specified folder but if you’re running the script on multiple folders then all the originals get copied to the same folder.

4_copy_finder_items_optional

Resizing Images

By adding a Scale Images action you’re able to resize them by pixels or percentage. I just use the pixel option, and make note that this will resize the highest value (height or width) to the specified value. So, for example, if you have a portrait image, the height will be resized to the value you entered.

4_scale_images

Rename and Change Case

Some cameras insist on naming their pictures with uppercase and spaces in the file names. To make them easier for browsers to use, you can change their case and rename them by using the Rename Finder Items action. Below is the Change Case part of this action:

5_rename_finder_items_change_case

If you want to change case and rename, like changing spaces to underscores, you don’t need another Automator script for it; you can just append another Rename Finder Items but selecting Replace Text instead of Change Case.

6_rename_finder_items_replace_text

And that’s just a couple of very easy Automator Scripts to quickly, and easily, resize, rename and change case on hundreds of pictures in a matter of seconds. I may look into passing variables to the Copy Finder Items action and, if I do, I’ll add that info here as well.