Frequently we need to clean a directory before zipping it or copying it to an external USB drive to be used by Windows or Linux users.
Apple Finder has the custom of populating directories with those unavoidable .DS_Store files, volumes with .Trashes, and some files (especially pictures) with ._resources. The following interactive script will safely remove these files prior to copying.
#!/bin/sh
# bash script to clean (delete) Finder .DS_Store, .Trashes and ._resources
# Use cleandsstores.sh
# juanfc 2010-03-06
if [ $# != 1 ]
then
echo "ERROR: use\n\t`basename $0` dirtoclean"
exit 1
fi
res=`find "$@" \( -name ".DS_Store" -or -name ".Trashes" -or -name "._*" \) -print`
if [[ -z $res ]]; then
echo "nothing to delete"
exit 0
el...







Go to Source
Mar 08
I use a couple of shell scripts that use Growl to remind me to run SuperDuper backups. The first script (backupcompleted) is set to run after each SuperDuper backup. It writes a timestamp into an invisible file called .lastbackup in my home directory; here’s the script:
#!/bin/bash
# This script is run by SuperDuper each time a backup is completed.
date "+%s" > ~/.lastbackup
The second script (lastbackup) reads the .lastbackup file and calculates the time elapsed. It takes one argument: the desired number of hours to wait before showing an alert.
If the elapsed time is greater than the time suppled to the script, it shows a Growl notification. If the elapsed time is greater than twice the time suppled to the script, it also increases the priority of the alert (so you can set a diferent colour for it in Growl preferences). Here’s the script:
…







Go to Source
Mar 08
Most of us know that Quicktime X, included with Snow Leopard, can trim movie and audio files. However, this trim is less than precise, as you cannot specify an exact trim start and stop point. Worse yet, if you want to make 10 minute segments for YouTube, you have to write down the last trim end time, undo the previous trim after uploading, and hope the trim slider will let you select the same trim point to start your next clip. What a pain.
Enter AppleScript — trim is a scriptable function. Open your movie in Quicktime X, and open the AppleScript Editor in the Application » Utilities folder. In the AppleScript Editor enter this script:
tell application "QuickTime Player"
activate
trim document 1 from start_trim to end_trim
end tell
Replace start_trim and end_trim with the time, in seconds, at which you wish …







Go to Source
Mar 08
Over the weekend, I plugged in my old-style 80GB iPod for the first time in, well, a long time — so long that the battery needed to be charged a bit before it would even sync. Once the sync started, things seemed to go well, but near the end of the photos section, iTunes displayed a message telling me there wasn’t enough room to copy all my photos.
This was a bit odd, because best as I could recall, my iPod had about 20GB of free space the last time I synched. And while it had been a while, there’s no way I took enough photos to fill 20GB — especially at the iPod’s resolution (I don’t sync full-sized copies).
I noticed that the Other (orange) section of the Capacity gauge in iTunes was huge — basically all the remaining space was used up by Other. Switching to the Finder, I quickly scanned through the various folders with the Inspector open (Command-Option-I), and they all looked normal in size … until I got to Photos » Thumbs. This one was over 20GB! G…







Go to Source
Mar 05
If you regularly use a language that requires letters with diacritics — such as á, ä, é, ë, í, ã, ñ, õ, etc. as they are used in Spanish, French or Portuguese — and you recently switched from Windows to Mac OS X as I have, you might find this hint useful.
In Windows, while there were various ways to enter these characters, the best one of them was just to enter a ‘ and then the vowel, and you would get the accented version of that letter (in this example, the letter with the acute diacritic).
In Mac OS X however, if you set the keyboard layout to a language that has these letters (such as Spanish), you cannot use this trick; the only way of inputting these letters is the standard way supplied in Mac OS X (Option-e then e for é; Option-e, then i for í; etc.). I personally found this very annoying, and searched for…







Go to Source