Friday, 16 April 2010

nifty little renamer

I'm pretty stoked about a little Automator function I set up to handle a problem I deal with a lot as a web developer - bulk renaming files...

So first, the problem. I get a bunch of 15 or 50 files to use as assets online, either documents or images for a gallery or something. So, more often than not they come like this:

Points tO the KEYNOTE SPEAKER.doc
NewsLETTER version 4.0.pdf
etc

Now, spaces are bad on web, and caps are dreadful. When dealing with a unix server it's worse because you have to match the case exactly. So, mac users - fire up nifty Automator... Let's create a Service:


You'll want to click on the Service option (selected in the image) because that way you'll have your function added to any right click!









Then you'll want to do a couple of things. What I do is create an output directly, which in this case I've called "sized" on my desktop, because my original outputs were all resized images. I digress, create this directory wherever you want it.

Now, you'll see your screen divided into two halves, as indicated in this image. The left half lists functions you can use (arranged in a sort of category -> function drill down effect), and on the right is your flow.

You won't have any items in your flow section yet, so for starters, select "files or folders" in the drop down. This sets the service to expect input as files and folders.

Now, after doing that, you've told automator you're gonna give it files, you need to tell it what to do. So, for safety, start with a copy:

On the left window, in the Library under Files & Folders, find the "Copy Finder Items" task, select it, and drag it into the right-hand window.

Select your desired directory (I've checked "replace existing files").

Then find the "Rename Finder Items" task, and drag it across. Select the dropdown to "Replace Text". Enter a space into the Find: textbox. (I selected in basename only). I then entered an underscore ( _ ) in the Replace: textbox. This is now set to replace all spaces with underscores. You can change your options accordingly.

I also added another Renamer task to set the name to title case. I'll yet do another task which will set the extension to Lowercase. Wow, and save - all done. It's added to the Services menu.

Feel free to download the workflow I did here. Put it in your Services folder, in the Library folder in your user directory. [/Users/_your_username_/Library/Services].

A toaster to the person who picks up the irony in the download...

No comments: