Typing in a Search Bar Using UIAutomation on iOS

Wed 02 Nov

2011

For some reason, even though the UIASearchBar extends UIATextField, the setValue() method doesn’t seem to work. I encountered this problem and came across this post: http://www.escortmissions.com/blog/2010/9/6/ui-automation-app-input.html.

In the post, Carl shows how to type a letter at a time using the keyboard, so I figured I’d take the code he gave and put it into a function of my own.

function typeString(string, delay)
{
    var char;
    var delay = typeof(delay) != 'undefined' ? delay : 1;
    var localTarget = UIATarget.localTarget();

    for (i=0; i < string.length; i++) {
        char = string.charAt(i);

        if (isUpperCase(char)) {
            UIATarget.localTarget().tap({x:20,y:400}); // hit shift for capital Letters
        }

        localTarget.frontMostApp().keyboard().keys().firstWithName(string.charAt(i)).tap();
        localTarget.delay(delay);
    }
}

function isUpperCase(char)
{
    return char == char.toUpperCase();
}

// Example usage
target.frontMostApp().mainWindow().tableViews()[0].searchBars()[0].tap();
typeString("TeStIng");

The advantage to this method over using setValue() (if it actually worked), is that if you have live filtering of results as the user types, you can see if the filters are working as they should.

I did notice that a commenter on the post named Mike recommended to tap, delay, tap on the search bar and this allows you to use setValue(), but I wasn’t able to get this to work. However, I’m just as happy using the method above as it lets me more accurately simulate a real user’s actions, which is really what UIAutmation is all about anyway.

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

Find the Correct Version of Xdebug for your PHP Installation

Tue 23 Aug

2011

Just happened to come across a thread that pointed to this tool:

http://xdebug.org/find-binary.php

It’s a pretty simple concept. Just paste the output from the “phpinfo()” (web) or “php -i” (cli) into the box and it will tell you which version of Xdebug you need for your configuration. It doesn’t seem like finding the correct version should be so complicated, but this tool makes it a lot easier.

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

Multimail Resource for Zend Framework

Thu 18 Aug

2011

While working on a Zend Framework project the other day, I found a need to be able to send emails using multiple transports within a single application. After much Googling, I found that most people suggested to initialize the configuration in the controller responsible for sending the email. Although this works, it felt a little clunky to me.

I started by moving the configuration parameters from the controller to my application.ini to keep from hard-coding them in my application. This was better, but still not optimal in my opinion.

What I ended up with was a custom resource based on a combination of two out-of-the-box Zend Framework plugin resources – Mail and Multidb. The functionality is from the Mail resource, while the configuration and necessary initialization in the resource file are similar to Multidb.

<?php
/**
 * Multi Mail Resource
 *
 * Example configuration (works with Google Apps):
 *
 *
 *   resources.multimail.mail1.type = "smtp"
 *   resources.multimail.mail1.host = "smtp.example.com"
 *   resources.multimail.mail1.auth = "login"
 *   resources.multimail.mail1.username = "username1@example.com"
 *   resources.multimail.mail1.password = "password1"
 *   resources.multimail.mail1.ssl = "tls"
 *   resources.multimail.mail1.port = "587"
 *   resources.multimail.mail1.default = true
 *
 *   resources.multimail.mail2.type = "smtp"
 *   resources.multimail.mail2.host = "smtp.example.com"
 *   resources.multimail.mail2.auth = "login"
 *   resources.multimail.mail2.username = "username2@example.com"
 *   resources.multimail.mail2.password = "password2"
 *   resources.multimail.mail2.ssl = "tls"
 *   resources.multimail.mail2.port = "587"
 *
 *   resources.multimail.defaultFrom.email = "support@example.com"
 *   resources.multimail.defaultFrom.name = "Example.com Support"
 *   resources.multimail.defaultReplyTo.email = "support@example.com"
 *   resources.multimail.defaultReplyTo.name = "Example.com Support"
 *
 *
 */

require_once 'Zend/Application/Resource/ResourceAbstract.php';

class App_Resource_Multimail extends Zend_Application_Resource_ResourceAbstract
{
    protected $_transports;

    public function init()
    {
    	$options = $this->getOptions();

    	foreach ($options as $key => $option) {
    		$options[strtolower($key)] = $option;
    	}

    	$this->setOptions($options);

        foreach ($options as $id => $params) {

	    	if (!isset($this->_transports[$id])) {

	    		$transportOptions = $options[$id];

	    		foreach ($transportOptions as $key => $transportOption) {
	    			$transportOptions[strtolower($key)] = $transportOption;
	    		}

	    		$default = (bool) (isset($transportOptions['default']) && $transportOptions['default']);

	    		unset($transportOptions['default']);

    			$this->_transports[$id] = $this->_setupTransport($transportOptions);

    			if ($default) {
    				$this->_setDefault($this->_transports[$id]);
    				Zend_Mail::setDefaultTransport($this->_transports[$id]);
    			}

	    	}
        }

        $this->_setDefaults('from');
        $this->_setDefaults('replyTo');

        return $this;
    }

    protected function _setDefault(Zend_Mail_Transport_Abstract $transport)
    {
    	Zend_Mail::setDefaultTransport($transport);
    	$this->_defaultTransport = $transport;
    }

    public function getMail($id=null)
    {
    	if ($id === null) {
    		return $this->getDefaultTransport();
    	}

    	if (array_key_exists($id, $this->_transports)) {
    		return $this->_transports[$id];
    	}

    	throw new Zend_Application_Resource_Exception (
    		'Tried to retrieve a mail transport that was not configured.'
    	);
    }

    protected function _setDefaults($type)
    {
        $key = strtolower('default' . $type);
        $options = $this->getOptions();

        if(isset($options[$key]['email']) &&
           !is_numeric($options[$key]['email'])) {

            $method = array('Zend_Mail', 'setDefault' . ucfirst($type));

            if (isset($options[$key]['name']) &&
               !is_numeric($options[$key]['name'])) {

                call_user_func($method, $options[$key]['email'],
                                        $options[$key]['name']);
            } else {
                call_user_func($method, $options[$key]['email']);
            }
        }
    }

    protected function _setupTransport($options)
    {
        if(!isset($options['type'])) {
            $options['type'] = 'sendmail';
        }

        $transportName = $options['type'];
        if(!Zend_Loader_Autoloader::autoload($transportName)) {

            $transportName = ucfirst(strtolower($transportName));

            if(!Zend_Loader_Autoloader::autoload($transportName)) {

                $transportName = 'Zend_Mail_Transport_' . $transportName;

                if(!Zend_Loader_Autoloader::autoload($transportName)) {

                	throw new Zend_Application_Resource_Exception(
                        "Specified Mail Transport '{$transportName}'"
                        . 'could not be found'
                    );
                }
            }
        }

        unset($options['type']);
        unset($options['register']); //@see ZF-11022

        switch($transportName) {

        	case 'Zend_Mail_Transport_Smtp':

        		if(!isset($options['host'])) {
                    throw new Zend_Application_Resource_Exception(
                        'A host is necessary for smtp transport,'
                        .' but none was given');
                }

                $transport = new $transportName($options['host'], $options);
                break;

            case 'Zend_Mail_Transport_Sendmail':

            default:
                $transport = new $transportName($options);
                break;
        }

        return $transport;
    }
}

To configure the resource, just add the lines in the comments to your application.ini (changing the configuration to match yours of course).

Drop the resource code above into:

<zend_framework_project_root>/library/App/Resource/Multimail.php

Then, add the following to your application.ini to autoload it:

pluginPaths.App_Resource = "App/Resource"

In your bootstrap, add the following:

protected function _initMail()
{
	$this->bootstrap('multimail');

	$multimail = $this->getPluginResource('multimail');

	Zend_Registry::set('mail1', $multimail->getMail('mail1'));
	Zend_Registry::set('mail2', $multimail->getMail('mail2'));

	return $multimail;
}

Then, in your controller where you send your email:

public function sendMailAction()
{
	$mail = new Zend_Mail();
	$mail->setBodyText('This is a test of the Multimail resource');
	$mail->setFrom('username1@example.com', 'Username 1'); // Optional if you've set a default from
	$mail->setReplyTo('username1@example.com', 'Username 1'); // Optional if you've set a default reply-to
	$mail->addTo('sendingto@example.com', 'Example Recipient');

	$mail->setSubject('Testing Multimail');

	$mail->send(Zend_Registry::get('mail1')); // Optional if you've set a default transport

	$mail->send();
}

This is my first custom resource, so please use, abuse and critique it in the comments. I’m open to any suggestions you may have.

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

Setting up a PHP Debugging Environment with MAMP and Eclipse (PDT)

Mon 01 Aug

2011

This post was inspired from a post over at 10jumps.comhttp://10jumps.com/blog/mac-os-x-eclipse-pdt-xdebug-mamp?page=8.

Any PHP developer knows that it’s not always easy getting debugging setup with Eclipse. I’ve found that it’s gotten easier over the years I’ve been coding in PHP, but it’s still far from painless. The article above describes the settings necessary to configure your php.ini, but I’ll go through all the steps to get debugging setup on your local machine, starting with downloading Eclipse/PDT/MAMP all the way though hitting your first breakpoint.

Step 1 – Download Eclipse

We’ll use Eclipse for JavaScript Web Developers and then install PDT, since as of the Indigo release of Eclipse, there is not a PHP Developer specific version due to a lack of a package maintainer. Just download, extract and place it wherever you’d like. I put it in my Applications folder.

Step 2 – Download MAMP

The current version as of the date of this post is 2.0.1 and can be found here. Extract the downloaded file and run the package installer. By default it will place MAMP in your Applications folder.

Step 3 – Install PDT

In Eclipse, go to Help > Install New Software…

From the “Work with:” dropdown, select the Indigo update site. Then under the “Web, XML, Java EE and OSGI Enterprise Development” section, you’ll find PDT.

Check the box next to PDT and click next. Agree to the license and it should start to install. At the end of the install, a dialog may pop up asking you to restart Eclipse. If so, click “Restart Now”. After Eclipse re-launches, proceed to the next step.

Step 4 – Setup your MAMP server in Eclipse

Next, we’ll tell Eclipse about our MAMP server. In Eclipse, go to Eclipse > Preferences. Then in the box in the top left corner of the preferences screen, type “servers”. This should filter your settings allowing you to see an item labeled “PHP Servers”.

Select “Default PHP Web Server”, then click “Edit”. Set the “Local Web Root” field to the document root of the site you are attempting to debug, then click “OK”. Then click “OK” to close the preferences dialog.

Step 5 – Download the Komodo Xdebug extension

This part is the kicker. The Xdebug extension that ships with MAMP doesn’t always work, but the Komodo one does. Download the Komodo version of the Xdebug extension from the Komodo Remote Debugging Package Downloads page, rename it “komodo_xdebug.so” and place it in the extensions directory for the version of PHP you’re using.

To find out which directory this is, start up MAMP. Once started, it should launch a “Welcome to MAMP” page that gives a link at the top to your PHP info. In your PHP info, you should be able to find an “extension_dir” directive that will tell you the extensions folder that the currently running version of PHP is using.

Step 6 – Edit your php.ini to add the Xdebug configuration

The php.ini that ships with MAMP should have an xdebug section like the one below:

[xdebug]
;zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"

Find this section and replace it with the following, making sure that the path to komodo_xdebug.so is correct.

[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/komodo_xdebug.so"
xdebug.profiler_output_dir = "/tmp/xdebug/"
xdebug.profiler_enable = On
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.idekey=ECLIPSE_DBGP

Step 7 – Make sure your PHP configuration recognizes the Xdebug extension

Restart your Apache server in the MAMP console, then reload the PHP info page in your browser. (This is the same page where you found the extensions directory path). You should now see an Xdebug section in your configuration that looks something like this:

Step 8 – Setup your debug configuration

In Eclipse, go to Run > Debug Configurations… You should see a screen that looks like this:

Select “PHP Web Page”, then click the document with the plus or right click “PHP Web Page” to add a new launch configuration.

Select “XDebug” for the “Server Debugger” option. For the “PHP Server” option, leave “Default PHP Web Server” selected. Browse for the file you wish for the browser to open to when debugging starts. I personally don’t like the script to break at the first line, so you can either uncheck or leave checked the “Break at First Line” option depending on your preference. Leave “Auto Generate” selected. Your configuration should look something like below (obviously with a different value for “File”):

Click Apply, then Close.

Step 9 – Debug something

Add a breakpoint somewhere in your project by clicking in the gray column to the left of your code in one of your PHP files. For the sake of testing your new configuration, I would recommend adding a breakpoint in the same file you selected in your launch configuration.

After you’ve added your breakpoint, click Run > Debug Configurations… Then select your newly created configuration and click the “Debug” button. Eclipse should launch your browser at the URL you specified in your launch configuration (with a few additional parameters that allow XDebug to work) and stop at your breakpoint.

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

jQRef is Live in the App Store

Sat 30 Oct

2010

My latest iPhone app went live yesterday. jQRef is a jQuery reference app for iPhone, iPod Touch and iPad. It allows you to access the latest jQuery documentation when you’re on the go or even without a data connection. It includes all the latest features from jQuery 1.4.3. Below is the App Store synopsis.

★★★★★
jQRef comes complete with the latest documentation from jQuery, including features from the NEW 1.4.3 release.
★★★★★

Have you found yourself working offline on a jQuery project, or simply had the need for a handy, easy to browse pocket jQuery reference? If so, jQRef is the app for you.

Features:
★ The latest jQuery documentation in an easy to browse format.
★ Code samples from the jQuery website.
★ A robust search, including filters for categories, methods, properties and selectors.
★ The ability to save favorites for even faster reference in the future.
★ Works offline when you’re on the go and/or without a data connection.
★ Browse by category or even jQuery version number.

Categories include:
+ Ajax
+ Attributes
+ Core
+ CSS
+ Data
+ Dimensions
+ Effects
+ Events
+ Forms
+ Manipulation
+ Miscellaneous
+ Offset
+ Plugin Authoring
+ Properties
+ Selectors
+ Traversing
+ Utilities

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

Xcode: When “Validate Application” Does Nothing, Console.app is Your Best Friend

Wed 20 Oct

2010

I just solved a problem that had me up until 2am last night and wasted about two more hours tonight. Hopefully this will help someone else spend a little less time on this issue should they encounter it.

I had just finished my newest iPhone app and was ready to submit it to the App Store. I used the “Build and Archive” option in the build menu of Xcode (as I had several times before), brought up Organizer and clicked “Validate Application…”. It prompted me to select my application and provisioning profile. I clicked OK.

Waiting…

Waiting…

Waiting…

Nothing! No message. No firewall activity. Nothing at all.

Googling. Googling. Googling some more. Came across a few things, but nothing solved my problem.

I had read somewhere a few days ago about Apple logging things that happen in Xcode to the system logs without telling you about it in Xcode, leading to mysteries like the one I had on my hands. So I opened up Console.app (/Applications/Utilities/Console.app) and started poking around.

What I found was this:

This told me a few things:

  1. That the IPA creation had failed.
  2. The command that Xcode was trying to run when I built my app.
  3. The error message that occurred when the command ran.

To make a long story short, in an effort to preserve the ability to test older OS versions in the simulator, I had installed the latest version of Xcode in an alternate location from the usual “/Developer” path that it defaults to. I do this (as many other iOS devs do) because even though Apple allows you to set your deployment target to something less than the current version, they like to remove all of the older SDKs every time they release a new version of Xcode. Turns out, I had put a space in the folder name.

In case you’re wondering, I’m still not sure why I ended up using ‘Developer 4′ as a folder name for Xcode 3.2.3, but that’s neither here nor there. My guess is that it was another of those 2am coding sessions. :)

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

Compiling iPhone Apps with the Latest SDK While Preserving Backwards Compatibilty

Sat 16 Oct

2010

Although you will most likely want to use the latest versions of Xcode and the iPhone SDK for your development, you’ll probably want to support devices running older versions of the iPhone OS as well. However, when you create a new project with the latest version of Xcode and the latest SDK, Xcode’s project template will automatically set your application to only support the latest iOS version. Here’s how to fix that:

In your Files and Groups pane, expand the Targets section.

Double-click the target you are compiling. You should see something like this (you may have to click the build section at the top):

In the search bar at the top, start typing “deployment target”. The list should begin to filter and you will eventually see a setting called “iOS Deployment Target”. Set this setting to the minimum iOS version you wish to support.

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

XCode iPhone Base SDK Missing

Sat 16 Oct

2010

This is a problem that I see a lot in the iOS development forums. You’ve recently upgraded XCode and/or downloaded a project of some sort from the web and you are presented with this:

XCode won’t compile your project, and instead gives you this or something similar depending on the iOS version:

error: There is no SDK with the name or path 'iphoneos4.0'

The thing is, Apple has a habit of removing old SDKs when they release a new version of XCode. The base SDK is saved in the project level build settings, so naturally, when you open a project with, for example, a base SDK of 4.0 in XCode 3.2.4/iOS 4.1, you’ll get this message.

Although this is annoying, there’s a fairly simple fix. In your project’s groups and files pane, expand the Targets section:

Then double-click on the target you are attempting to compile. You’ll see something like this (you may have to click the build section at the top):

You should see a setting called “Base SDK”. Change this to a valid SDK (one that doesn’t say (missing) next to it).

Next, click “Build and Run” and you should be all set.

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email

My First iApp – SwapTwo

Fri 09 Jul

2010

Three times since the iPhone came out, I’ve sat down and tried to learn Objective-C with the hope that I would be able to create a full-fledged application that I could submit to the Apple App Store. The first two times I gave up due to lack of a good idea, but mostly due to lack of motivation. A few months back, a co-worker created an app and it gave me the drive to start learning Objective-C and stick with it this time. About a week ago, I submitted my first app – a game called SwapTwo.

Since my blog has been sitting dormant for over a year, I figured now is as good a time as any to make a long overdue update. So, without further adieu, here’s a link to my first app.

http://swaptwo.borloz.com

If you have an iPhone, iPod Touch, or iPad, please download it. If you like it, please rate it.

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email
Filed Under: apple, iPhone | Leave a Comment 

AppleScript to Ease the Pain of the MINI Audio Interface

Thu 26 Mar

2009

About a year ago, I bought a MINI Cooper and I love pretty much everything about it except the audio interface. It seems when they were designing the MINI, the audio interface was last on the list of things to make easy to use.

My main gripe is the scroll knob. It’s fine for switching radio stations one at a time, or flipping through tracks on a CD, but when you have an iPod or a flash drive plugged in with a sizable amount of music on it, getting to the music you want to hear is often painfully slow. The problem is that no matter how fast you turn the knob, it scrolls through the music at a constant pace (slow).

I came up with an idea a while back to ease my pain and just got around to finishing it last night, so I thought I’d share. I wrote an AppleScript that organizes folders according to the letter they begin with. So, for example, let’s say you have a flash drive full of music that’s organized by artist (like iTunes organizes your music folder). The script will take all of the artist folders that begin with “A” and put them in the “A” folder, “B” in the “B” folder, etc. This way, when you plug the flash drive into your MINI and use the “DIR” option to browse the drive, you have a maximum of 27 folders to scroll through (one for each letter of the alphabet and one for artists that start with 0-9).

A few notes about the script:

  • First and foremost, I’m not responsible if the script reorganizes your music library in an undesired manner. The script worked for me using the steps provided on my Mac running OS X. However, I can’t predict all of the different factors that may cause the script to fail or sort your music incorrectly. I would suggest that you copy (not move) any music you run the script on to a separate folder other than your music library. This way, if something happens, it’s just a copy that you can delete and your music library will remain in its original state. Now that I’ve release myself from liability, if you do find a bug in the script, please let me know by leaving a comment.
  • The script is written in AppleScript, which will only run on Apple computers. If you are running Windows, I’m sorry, but the script will not work. I may look into writing something that’s Windows compatible if there is enough demand, but for now it’s Apple only.
  • Any folders that begin with “The ” will be placed in a folder according to the first letter of the second word. For example, “The Killers” would be placed in the “K” folder.
  • Any folder that begins with a non-alpha character (such as a number or special character) or begins with “The ” and the 5th character of the folder name is a non-alpha character will be placed in the “0-9″ folder.
  • Only necessary folders will be created. So, if you don’t have any folders that begin with “B”, a “B” folder won’t be created.
  • I used the script to organize my music by artist because this made the most sense to me, but there is nothing that should prevent you from using it on any folder. For example, if your music is organized by album and you want to sort it into folders based on the first letter of the album, it should work just the same.

Preparing your music for the script:

Since this is a fairly simplistic script, it relies on your music being somewhat presorted. If your music is not already sorted by artist, iTunes can do it for you:

  1. Open iTunes
  2. Click iTunes in the menu bar
  3. Click Advanced
  4. Check the “Keep iTunes Music folder organized” option

Installing the script:

  1. Copy the script to /Library/Scripts (you should see a bunch of other scripts that come with OS X in this folder).
  2. If you have the script menu icon in your menu bar (it looks like a little paper scroll), skip to “Running the script”.
  3. Open the AppleScript Utility. It can be found in /Applications/AppleScript/AppleScript Utility.
  4. In the Applescript Utility, check the “Show Script menu in menu bar” option.
  5. Close the Applescript Utility. You should now have the scroll icon in your menu bar.

Running the script:

  1. Click the AppleScript icon in the menu bar and select the “MINI Music Organizer” script in the drop down menu.
  2. Select the folder that contains your music organized by artist.
  3. Click Choose
  4. That’s it. The script will take anywhere from a few seconds to a few minutes to run depending on how much music you have. When it’s done, use Finder to browse to the folder you just ran the script on. It should now be organized by letter.

Download the script:
MINI Music Organizer.scpt

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • del.icio.us
  • Google Bookmarks
  • Tumblr
  • Digg
  • StumbleUpon
  • LinkedIn
  • DZone
  • HackerNews
  • Posterous
  • BlinkList
  • NewsVine
  • Technorati
  • blogmarks
  • Fark
  • Live
  • MisterWong
  • MySpace
  • ThisNext
  • Slashdot
  • Yahoo! Buzz
  • Suggest to Techmeme via Twitter
  • PDF
  • email