•
Many of the digital photo frames on the market still don’t have the ability to shuffle images and display them in random order. A couple people I know have frames and want to mix up the photo stream a little. The first time I ran into this issue I used a Windows utility called renamer to assign random names to the image files. But what about a pure Mac solution?
There is one, and you don’t need anything other than OS X to get it done. Skip to the screencast if you prefer - otherwise here’s what you do:
Place the files to be renamed in one folder. It’s best to have them all in one folder without subfolders. If you have images scattered inside subdirectories you’ll have to make some adjustments to these instructions. USE A COPY OF YOUR ORIGINAL IMAGE FILES, there’s no reason not to.
Open the Terminal from your Utilities folder in Applications. Type cd followed by a space. Then drag the folder containing the files from Finder to the Terminal window. Hit return. The Terminal prompt should update to indicate you’re now in the directory containing the images. This folder should NOT BE THE SAME AS THE ONE YOUR ORIGINALS RESIDE IN. Sorry for that, but it’s important.
Finally, type the following command in the Terminal:
for i in *.jpg; do mv $i $RANDOM.jpg; done
The command is case-sensitive. If your images have names ending .JPG you’ll need to adjust the *.jpg part of the command above to use a capital JPG.
Hit return and your image files are renamed using random numbers. Copy them to the digital photo frame and your images should cycle randomly. Thanks to this thread at Mac Rumors Forums.
I’ve included a screencast for those not familiar with Terminal. Be careful in the Terminal. You can delete files accidentally and they won’t be in your Trash ! See this warning for more information.
Screencast
|
Permalink
•
Remember when iTunes used to have a Library container that you could select as the basis for a search of ALL your content? That was nice. Now if you want to search for a TV show in the library you need to click on the TV Shows node before initiating a search.
If there were a keyboard shortcut to select each container I’d use it, but I don’t see any such shortcuts. Thanks to the king of AppleScripts for iTunes I’ve pulled together some pieces that give me a solution.
If you really miss the all-inclusive Library container you can add it back into iTunes using an AppleScript application provided by Doug Adams called Change Hidden iTunes Preferences. From there you can script selection of that container or you can go a step further: I’m using TextExpander to kick off a script that facilitates iTunes searching. The script can select the Library container or go on to select a container like TV Shows, Movies, or Podcasts. The extra step is only required if you prefer to have search results limited by media type.
The commands to select the Library container were provided by Doug. When hooks for selecting other containers weren’t readily apparent (maybe they’re there and I didn’t see them) I moved on to another strategy: Selecting the Library and then scripting arrow key presses to move down the tree. So far that works ok. Last step: Place the cursor in the search box. Doug’s page on automating keystrokes helps there too.
The simple script, shown in the screenshot, can be kicked off with a keyboard shortcut. For me it means not using the mouse, and that’s worth the effort. Still, the script isn’t working 100% of the time. For example, if the Library node is already selected it fails. Needs a little work…
Murphy's Web Host
|
Permalink
•
This is a quick way to make encrypting files using the terminal fast and convenient. Murphy posted instructions on making an interactive shell script to do essentially the same thing. This is a slightly different spin. Skip ahead to the screencast to see how easy file encryption can be. The openssl command we’re using is included with OS X.
Like other things we’ve covered - the specific example might not apply to you - but for people who’ve never used a function it might be helpful. Functions can make complicated Terminal commands more convenient to use.
To create the function just add this line to the .bash_profile file in your home directory:
des3() { openssl des3 -salt -in "$1" -out "$2"; }
Note that there’s a space after the opening curly bracket and a space before the closing curly bracket. All we need to remember is the function name, and to provide two file names: one to encrypt and one to be the output file.
The breakdown on the command: the first des3 is what we named the function. We can name it anything but des3 is what Murphy chose. The name of the function is what you’ll type whenever you use it.
The stuff in the curly brackets is what happens when we invoke the function. See this post for more on the openssl command.
The des3 following the openssl command is the type of encryption we’re using. It’s part of the openssl command syntax. We added $1 and $2 after the in and out respectively because they’re the two pieces of information we need when we invoke our function.
The $1 and $2 will be replaced with the paths we type into Terminal. In the screencast Murphy shows how to invoke the function. Instead of typing the paths he drags the file to be encrypted into the window - which saves us the typing. He also names the output file with a des3 extension to remind himself how he encrypted the input file.
As always, be careful with the Terminal if you’re not familiar with it. See Murphy’s warning about the dangerous possibilities.
Watch Screencast
|
Permalink
•
Wait until you see what a clever pun this title is. Using the sleep command in Terminal you can update your Twitter status while you’re away. Or sleeping.
Apple has jumped around a little with regards to command line scheduling tools, but the sleep command is still dead-simple to use. (Read more about scheduling with lingon and launchd here)
Suppose you have a command you want to run once, at a future time. Use sleep followed by the number of seconds to wait. Then use a semi-colon to separate the command to run at the appointed time.
sleep 30 ; command
The above example will execute command 30 seconds after you hit the return key. 3600 seconds is an hour. 86,400 seconds in each and every day.
So now you just need a command to update Twitter. The curl command comes with your Mac. Twitter Development Talk boasts the easiest way to update Twitter from the command line. Scroll down to The Easiest Way to Play Around with the Twitter API. Christopher Penn has a post on it too, but the command is cut-off on his blog.
The command should look like this:
curl -u username:password -d status=”your message here” http://twitter.com/statuses/update.xml
Enter that all on one line. It would be better to make it into a shell script. Just copy that line into a text file, maybe name it tw.sh, and replace the your message here part with $1. Then use chmod to make it executable.
Note: Don’t know how to make it executable? Read more about making a shell script. Learn even more about shell scripts: make an interactive shell script.
From there you can enter the following in the Terminal:
./tw.sh “Looking into starting my own airline…”
And you’ve updated your Twitter status. You can make that cleaner by setting an alias for your shell script.
Finally, to have your tweet post onto Twitter hours later you could enter something like this in the Terminal:
sleep 7200; ./tw.sh “I’m sleeping” (you’ll need to leave your Mac on)
If you’re a stickler about your Twittering and want to be accurate, this is the way to go. Schedule that I’m in the shower tweet in advance. People need to know.
|
Permalink
•
This post is intended for people with mobile phones that don’t have Internet access, but can receive emails in the form of text messages. You will also be interested in this post if you’ve had problems with Mail.app rules in Leopard.
Need to check for new messages in Mail.app from your stone-age mobile phone? No problem. Send yoursef an email with a preset subject like “MsgFetch” and your unread emails received that day will be forwarded to your phone. This way you don’t always forward to your phone, burning up all your text messages.
The script will append the sender name into the subject so it’s easy to glance at your phone and see who sent each message - since they’re all forwarded from your email address. The messages are marked as read in Mail.app so they won’t be resent if you issue another request later.
One more thing: This solution also gets around a problem with rules in Mail.app under Leopard. It seems that scripts called by a rule won’t generate a new mail message, which is something this script needs to do.
Instead of relying on the rules of Mail.app, the rule processing is baked into the Applescript. By setting the script to run on a periodic basis we can test for trigger emails in the inbox.
How do you get the script to run periodically? You can have iCal do it. Or you could use something like Lingon to configure launchd, which handles scheduled tasks in Leopard. This post has a screencast that covers Lingon.
You could also create a shell script that kicks off your Applescript, or a group of Applescripts for that matter. The shell script would look something like this:
osascript <path to script file>/ <script file>
or
osascript ~/Documents/scripts/mailforwarder.scpt
You can download the Applescript and read the in-line comments explaining how it works. But let’s take a quick look at two excerpts from the Applescript:
The first part of the script handles what a Mail.app rule would normally cover. Since rules aren’t working as expected the Applescript handles that duty by looking for an unread email with MsgFetch in the subject. If there is such a message the script calls a subroutine ( a chunk of script) called mail_forwarder.

The other part we’ll look at is located within the mail_forwarder subroutine. It finds the emails that arrived today. The next part, not shown here, checks to see if the message has been read.

The rest of the script has been covered in other Murphy Mac posts. It’s the part that creates and sends the mail message. Murphy’s posts on mailing files from Finder and retrieving files by email both create and send mail messages using Applescript. The Finder post has a screencast that goes with it.
Related posts:
Using Lingon
Creating a shell script
Other tricks with Mail: Pick a Playlist by Email - Retrieve a File by Email - Mail a File Dropped in a Finder Folder
Download Applescript
|
Permalink