Joe Maller.com

Joe’s iPhoto AppleScripts Updated

Joe’s iPhoto AppleScripts for Date Manipulation have been updated. I’ve been working on these for a while towards the goals of making Automator actions and a standalone Application, but some unknown incompatibility introduced by iPhoto 5.0.4 pushed this to the front burner.

Some areas of improvement:

  • Better UI Date Entry – Dates entered directly in info pane, no more popping the Batch Change window
  • Language Independence – All language specific UI calls removed, should work with any language or date format
  • Date format sniffing – The date format is now discovered gracefully and checked for accuracy.
  • Faster – Extensive refactoring and efficiency tuning, now I can really blame iPhoto for the slowdowns.
  • Works with iPhoto 5.0.4 – I’ve been testing it all evening with absolutely no problems (I probably shouldn’t say that)

I still don’t know why the previous scripts stopped working with 5.0.4, but I was thankfully able to get these all working with the newest iPhoto in a few hours this morning. Good application design really does make a difference. I know I’m still not working in true OOP, but breaking the code down into simple, self-contained chunks really makes maintenance simpler. The return curve (that agonizing time spent staring one’s own code and having no idea how it works) is much shorter when each component is named descriptively, has a concise, easy to grasp function and doesn’t draw from anything but it’s explicity input parameters.

Idea for next time: If these scripts obliterated the existing clipboard, would that be a dealbreaker? Or just an annoyance? What if they ran a lot faster?

Share |

link: Aug 05, 2005 12:35 am
posted in: Mac OS X
Tags: ,

Store and Retrieve Pasteboard with AppleScript?

I’m looking for a way to save and restore pre-existing clipboard data.

I have a few Studio projects that use UI scripting. Sending text to a non-scriptable control by pasting from the clipboard is significantly faster than using the Keystroke command. What I’d like to do is store the complete contents of pasteboard “general”, execute my UI stuff, then repopulate the pasteboard with the archived values.

Because my goal is to leave the clipboard data as I found it, this needs to work with any kind of clipboard data. The problems I’m having relate to complex data being dumbed down. For example, an image copied from Safari becomes a plain text URL after storing and retrieving. Conceptually, moving a big lump of data should be possible, regardless of supported formats.

One other related question: Is the list returned by types of pasteboard “general” prioritized? If I had to pick one of the returned types, how would I know which was best?

MacScripter: Store and Retrieve Pasteboard

Anyone have an idea about this one?

Share |

link: Aug 05, 2005 12:25 am
posted in: Mac OS X
Tags:

AppleScript UI Elements Hiccup in 10.4

I was having a problem with AppleScripts which use UI Scripting in 10.4. Something was corruping the result of System Events’ UI Elements Enabled boolean, causing script execution errors whenever that item appeared in a script. Joe’s iPhoto AppleScripts use GUI scripting, so this bug stopped them from working. Deleting the preference file “com.apple.universalaccess.plist” and restarting fixed the problem for me.

Share |

link: May 02, 2005 12:09 am
posted in: Mac OS X
Tags:

Faster Trash Size AppleScript

For whatever reason my Finder sometimes takes forever to calculate the size of the Trash. That doesn’t include the clicks of opening a Trash window, selecting all, then getting info. Here’s a script which is much faster: Faster Trash Size (click to open in Script Editor)

Nothing special, just a quick AppleScript wrapper for this simple terminal command: du -h ~/.Trash | tail -rn1 | awk '{print "Size of Trash is " $1}'

It’s three quick commands:

  • du -h ~/.Trash
    Disk Usage, the “-h” flag reports sizes in human-readable values, the directory to report is ~/.Trash, which is the current user’s Trash folder. This dumps a size report for every item in ~/.Trash followed by a total at the bottom. That output is then piped out to tail:
  • tail -rn1
    Tail reads the end of files or the standard input, in this case the output of du. The “-r” flag reverses the output, then “-n1” prints one line. The output of this has only one line which looks like 2.9G /Users/joe/.Trash. That gets sent to awk for some simple formatting:
  • awk '{print "Size of Trash is " $1}'
    Awk is an amazing tool that I’ve only recently scratched the surface of. This particular command is a really just a simple echo statement which uses Awk’s column splitting ability to quickly split the output of du and tail. “$1” refers to the first column of the output, split on white space by default. I added a descriptive string to Awk’s print command to make the output a little more meaningful and prettier.


« Previous Page