Showing posts with label automation. Show all posts
Showing posts with label automation. Show all posts

Friday, December 22, 2006

Desktop Cleaner

I was watching the latest MacBreak Weekly video because I love Merlin Mann and track him incessantly, and he mentioned the application Hazel (Mac OS 10.4+). The theme of the videocast was things to help you un-distractify your Mac, and Hazel fits the bill by cleaning up extraneous files and doing things with them.

I thought this app would be perfect for cleaning up after Firefox. I specified a Temporary folder for it to download things to, but that only works when I save files and not when I select "Open in...". So I browsed around the Hazel website for a while, but my college student instincts ("Don't pay for anything you can get a functional facsimile of for free/cheap or make yourself") kicked in, and I decided to make such an application myself.

I was able to use Automator, while learning some in the process, to cobble together a working application that gets any documents, images, or disk images and moves them into that file type's respective subfolder in my "Desktop Cleanup" folder. I say "working" because it's not very ideal. For one thing, the program finds any files on the desktop or (and here's the problem) any FOLDERS that are on the desktop. Sort of annoying, but I can move those folders and put aliases to them on the desktop instead. Another problem is that, if there are any files that don't fit into the 3 categories specified, you have to manually move them OR add another Action to the workflow. I'll probably be changing it as I go along.

Eventually I'll upload the workflow and the application, but for some reason I can't upload anything from where I am now. For now, you'll have to settle for an explanation. The workflow just consists of pairs of linked commands:
  1. Find Finder Items
  2. Move Finder Items
I've set each Find Finder Items command to find items matching one criterion having to do with the kind of file it is: Kind=Audio, Kind=Document, Extension CONTAINS dmg, Extension CONTAINS zip, and Kind=Image. Audio needs to come before Document because otherwise the program will count some music files (.m4p at least) as documents. The reason that's a problem is because I have each Move Finder Items command set to move the found items to a certain type-specific subfolder of my "Desktop Cleanup" folder. Also, it's important to make sure to select "Ignore Results from Previous Action" for each Find Finder Items command, so that the sequence for each file type is separate from its neighbors.

Thursday, December 21, 2006

Batch Renaming Files in Mac OS X

So, iPhoto screwed up my library AGAIN (I reeeeaaallly wish Google would make a Picasa for Mac), and I was getting sick of having to look at every one of my several thousand photos and put it in the right folder, along with classifying them as originals, exports for upload, or edits. I decided that renaming the picture files was the only way I could save myself this trouble the next time this happened. Long story short, I was about to give up on my search for a free renamer for Mac and shell out 20 bucks for payware (I shudder at the thought) when, in an act of desperation, I scanned the comments on all the Lifehacker posts about renaming files in bulk (which pertained, annoyingly enough, only to Windows).

Luckily, one commenter had mentioned the free app NameChanger for Mac OS X. I just about cried when I used it for the first time, that's how awesome it is. The program allows you to drag-and-drop files to rename onto the icon or into the program, and shows you a live preview of what the filenames will look like after you're finished.

Later, while playing with Automator (which comes with Tiger) for my Desktop Cleaner program, I discovered that Automator can rename photos. By selecting "Show Action When Run," it's possible to specify what to replace and what to replace it WITH. However, NameChanger has several advantages.
  1. No programming required. Just download and extract, and it's ready to go.
  2. As-you-type preview. A little gimmicky, but cool.
  3. Ability to replace first, last, or all occurrences of a term.
But the Automator option has some things going for it too, such as the ability to put a date before or after a name (NameChanger can only put it after); the ability to use date created, modified, or current date; and different customizability of dates. But for me, it's much nicer to just download a program that does the work for you.