Tag: efficiency

Earlier I wrote an Applescript that goes online to TV.com and finds the episode titles for TV show video files. While that seemed to work properly, TV.com changed their format and my Applescript went kaput. Since I really wanted to have this process automated, I wrote a bash script to do the same thing with the command line.

The result is a Ubuntu bash script that renames all the formatted files in a folder with the actual episode titles. Right now it requires Linux because it uses wget and XMLStarlet to download the file data, but I may release an additional script that works with other systems.

The entire script is made possible by the excellent XML feed service by TVRage.com.

Download the script

Prerequisite

XMLStarlet
XMLStarlet is a small command-line utility that can process XML files and text. It is required to traverse the XML structure of the TVRage.com data. To download this utility in Ubuntu, simply use the repositories.

sudo apt-get install xmlstarlet

Usage

Change paths where appropriate.

  1. Save the script to a known folder, change into that folder, and make it executable by issuing the following command
    chmod a+x ./tvrenamer.sh
  2. Change the current directory to the folder that contains the video files.
    cd Television/Season\ 1
  3. Rename all the files in the folder to use the format SxxExx.extension
    S08E01.avi
    S08E02.avi
    S08E03.avi
    S08E04.avi
    S08E05.avi
    S08E06.avi
    S08E07.avi
    S08E08.avi
    S08E09.avi
    S08E10.avi
  4. Call the script and append the name of the show to the end of the command.
    /path/to/script/tvrenamer.sh Simpsons
  5. Watch as the shows all magically change their name.
    Downloading show data for 'Simpsons'...
    Downloading episode guide...
    Simpsons - S08E01 - Treehouse of Horror VII.avi
    Simpsons - S08E02 - You Only Move Twice.avi
    Simpsons - S08E03 - The Homer They Fall.avi
    Simpsons - S08E04 - Burns, Baby Burns.avi
    Simpsons - S08E05 - Bart After Dark.avi
    Simpsons - S08E06 - A Milhouse Divided.avi
    Simpsons - S08E07 - Lisa's Date with Density.avi
    Simpsons - S08E08 - Hurricane Neddy.avi
    Simpsons - S08E09 - El Viaje Misterioso de Nuestro Jomer (The Mysterious Voyage of Homer).avi
    Simpsons - S08E10 - The Springfield Files.avi

If you wish to access the script simply by typing the name (tvrenamer, for example) simply issue the following two commands:

cp /path/to/script/tvrenamer.sh /usr/local/bin/tvrenamer
sudo chmod a+x /usr/local/bin/tvrenamer

From this point, you simply need to use tvrenamer "TV Show".

The script reads all files in the folder, but will only rename files that are in the S**E** format. TV show titles must have escaped spaces to properly search for the show, or be surrounded in ” quotes.

Tagged with: , , , ,

Maybe you’ve bought a new computer and can’t use Migration Assistant, or maybe you need to restore your data after it has been corrupted. Whatever the reason, you’ll be happy to know that replacing the data in Address Book, iCal and Keychain is as easy as replacing a file. Since OS X stores data inside standard text files, all data associated with a specific application will be found inside the user library.

Here’s where to find them.

Address Book

Navigate to userfolder / Library / Application Support / AddressBook. Inside that folder is a number of strange and mysterious file names. The one you’re looking for is AddressBook.data. If you try opening that file in a text editor, you’ll see gibberish because it is a binary data file.

Transfer that file to another Address Book instance (in the same folder), restart the application, and you’ll have all your contacts again.

Keychain

Restoring the Keychain, while basically the same process, requires slightly more work to complete. Navigate to userfolder / Library / Keychains and look for login.keychain. This file stores all the passwords and website form details that are collected whenever you save them. “Login” is the master keychain that the system always looks for. If you’re replacing this keychain with another backup, you’ll have to unlock it before you can use it properly again. To do that, open Keychain Access (inside /Applications/Utilities) and select Unlock Keychain “login” from the File menu. Enter your administration password, and you’re good to go.

iCal data

Backing up iCal calendar data is much easier if you export the calendar from inside iCal. To do that, select the calendar from the list on the left side of the window, and choose Export from the File menu. That will produce a file with a .ics extension that can be imported into iCal by double clicking the document.

If you’re looking for the iCal data specifically, the calendar files are located at userfolder / Library / Calendars. The problem with this method is that the calendars are stored inside a cryptically-named folder that can only be distinguished by opening the info.plist file inside the folder. Using the folder itself is probably only necessary when you need to rescue data and iCal cannot be opened.

Thanks to the file organization of Mac OS X, you can be sure that important personal data can be recovered or backed up if there is a problem.

[tags]Mac OS X, iCal, Keychain, Address Book, backup, troubleshooting[/tags]

Tagged with: , , ,

It’s funny how solutions to problems come out of the blue. I was in the process of converting a number of .aif audio files to .MP3 with ffmpegX when I happened to pick up the April 2006 edition of Macworld and found a program that could speed up the process under the Tools of the Trade section. That program was called Max.

Max is a versatile, easy to use application does one job: convert audio. It takes in audio files of many formats — multiple files — and can convert them to many others. I was happy to find this program because it can convert to MP3. Other programs like Quicktime Pro and Audacity don’t have this ability.


To use Max and output to any format of your choosing, you open the preference panel and select the format you need. I only used MP3, but there are an abundance of other formats available.


After you’ve selected the correct format and output folder, it is a simple matter of draggin any audio file into the queue and pressing Convert. Max takes it from there and gives you a complete collection of your original tunes in their own formats. This batch processing ability makes it a tool that I will be using for a long time.

Max represents another excellent piece of software developed for the open source community, and does a terrific job at its designed purpose.

[tags]Max, audio, convert, import, Mac OS X[/tags]

Tagged with: , , , ,

When you get an iPod, you’re faced with many decisions: should I put mostly movies on it? Which songs should I use? Should I manually manage the music, or can I leave it as automatic syncing?

While I can’t help you pick which tunes your iPod will contain, I can help you decide which method to use. Each has its own benefits and drawbacks, and can make using your iPod even more enjoyable.
Read More »

Tagged with: , , , , , ,

I’ve been frustrated recently because external hard drives connected to my MacBook have refused to unmount. After resorting to restarting before trying again, I posted my problem to a number of online forums.

Knowledgeable member of the Macworld forums oddlot answered my question with a Unix command called hdiutil that can force eject a drive.

I took this command and wrote a quick Applescript that displays a list of the connected drives and force ejects the one you choose.

I linked this up to a Butler trigger, so now if a drive is uncooperative, I can activate this script with one key combination.

If you wish to use this script as a simple application, copy the code listed into a Script Editor window (found in /Applications/Applescript). You’ll likely not need to change anything, but if your startup disk is anything other than Macintosh HD, you need to change the beginning variable startupDisk. Choose Save As from the File menu and pick Application from the dropdown menu. This will create an application that you can easily double click whenever you need it.

UPDATE: I realized after I posted this that the functionality is broken when the disk contains spaces in the name. The code posted here has been corrected.
[tags]Applescript, Automator, programming[/tags]

Tagged with: , , , , ,