⚡ standard output

A weblog of nerdy opinions and other detritus
by Michael Shane.

January 27, 2012 at 10:18am

A little Dropbox nerdery.

These days I use my Dropbox for as much as possible. I’m in there a lot. I share files via my Dropbox public folder whenever I can.

I also take a lot of screenshots. ‘⇧⌘4’ is permanently engrained in my muscle memory. Whether I’m communicating with colleagues in The Verge newsroom or trolling a friend, screenshots have become an essential part of my daily workflow.

When you share via Dropbox as much as I do, copying screenshots from ~/Desktop to ~/Dropbox/Public and then opening a contextual menu to copy the public Dropbox link to the clipboard is laborious.

Today I decided to find a solution to automate as much of the process as possible.1

The first thing I did was track down an AppleScript to watch my Dropbox public folder for new files and automatically copy the requisite public link to the clipboard whenever a new file appears in the directory. I found my answer in the Dropbox forums. This is the AppleScript:

on adding folder items to this_folder after receiving added_items
    try
        set the item_count to the number of items in the added_items
        if the item_count is equal to 1 then
            set theFile to item 1 of added_items
            set theRawFilename to ("" & theFile)

            set tid to AppleScript's text item delimiters
            set AppleScript's text item delimiters to ":"
            set theFileName to (text item 6 of theRawFilename) as text
            set AppleScript's text item delimiters to tid

            set theWebSafeFileName to switchText from theFileName to "%20" instead of " "

            set theURL to "http://dl.dropbox.com/u/YOUR_DROPBOX_ID_HERE/" & theWebSafeFileName
            set the clipboard to theURL as text
        end if
    end try
end adding folder items to

to switchText from t to r instead of s
    set d to text item delimiters
    set text item delimiters to s
    set t to t's text items
    set text item delimiters to r
    tell t to set t to item 1 & ({""} & rest)
    set text item delimiters to d 
    t
end switchText

Follow these steps to create and enable the AppleScript:

  1. Fire up AppleScript Editor2 and paste in the code above. (You can also download the script via the link in the post on the Dropbox forums.)

  2. Replace YOUR_DROPBOX_ID_HERE with your numeric Dropbox ID, which appears in URLs to public links in your Dropbox.

  3. Save the AppleScript.

  4. Copy the AppleScript to
    /Library/Scripts/Folder Action Scripts
    (You will need Administrator privileges.)

  5. Right-click on the Public folder in your Dropbox to open a contextual menu and select Folder Actions Setup

  6. Select your AppleScript from the list that appears and choose Attach.

  7. Check the box for Enable Folder Actions if it’s not already checked.

Congratulations! From here on out, any time you drop a file into the Public folder of your Dropbox, its public link will instantly copy to your clipboard.

But this solution only meets half of my needs. I use my Public folder for lots of different kinds of files, so I have a nested folder called “screenshots” to help keep my Public folder tidy. I needed to find a way to automatically send screenshots to this folder the moment I create them so that I can avoid the trouble of moving the files manually.

Step one: change the default save location for screenshots created using the native Mac OS X keyboard shortcuts from ~/Desktop to ~/Dropbox/Public/screenshots.

In case you don’t know, here are the keyboard shortcuts for taking screenshots in Mac OS X:

  • ‘⇧⌘3’ takes a screenshot of your entire screen.

  • ‘⇧⌘4’ captures an area of your screen selected with the mouse.

Using this shortcut you can also press spacebar to select individual application windows (then click your mouse to take the screenshot). The spacebar method allows you to get a perfect snapshot of a specific window and adds drop shadows. I used this method to create the screenshots in this post.

I’m the kind of nerd who’s very comfortable using the Terminal, but I don’t necessarily know every Unix command or “defaults write” trick by heart. If I want to customize an app or service, the Terminal command I’ll need is often a quick search away. In this case, the commands were straightforward:

     defaults write com.apple.screencapture location ~/Dropbox/Public/screenshots

~/Dropbox/Public/screenshots is the exact location of the nested folder within the Public folder of my Dropbox. You should insert the exact path for the folder you want to use, which may be different.

In order for the change to take effect you must follow up with this command:

     killall SystemUIServer

If you need to change the location again (or revert back to the default) simply follow these steps and replace ~/Dropbox/Public/ with the path of your choice.

So, let’s review what I’ve done so far:

  • I enabled an AppleScript that keeps an eye on my Dropbox public folder and automatically copies the public link for any new file that appears within.
  • I changed the default save location for screenshots from the Desktop to a nested folder within my Dropbox public folder.

I’m almost done, but my screenshots folder is not fully automated yet. The AppleScript I used to make my Dropbox a bit more self-aware is very specific. It only watches one folder for one file at a time, which means it does not see files that show up inside nested folders. In order to add the functionality I need to my nested screenshots folder, I need to repeat steps 4 through 7 from the first section of this post. But first, my AppleScript needs two slight tweaks:

  • Open up your AppleScript and find this line:

    set theFileName to (text item 6 of theRawFilename) as text
    
  • Replace the numeral 6 with the numeral 7:

    set theFileName to (text item 7 of theRawFilename) as text
    
  • Append your nested directory to the URL in the AppleScript.

  • Save the script with a new filename (I simply appended screens to the filename). Repeat steps 4 through 7 from earlier, with the follow adjustments: you should right-click on your nested folder instead of your Public folder this time.

And that’s it. From now on, whenever a file is copied to the Public folder in my Dropbox, its public link is autometically sent to my clipboard. Additionally, anytime I take a screenshot, it will automatically be saved to my nested “screenshots” folder and its public link will be copied to my clipboard.

This may only save me an hour or two of empirical time per year, but — more importantly — I’ve eliminated a source of friction in my daily workflow. The rhythm of my work every day will encounter fewer disturbances, which means that over time I can be exponentially more productive.


  1. There’s a slick Mac app called Slingshot that has this functionality and more, but I was looking for a completely invisible solution that would eat as few cycles as possible. I also wanted to get my nerd on. 

  2. Use Spotlight or look in /Applications/Utilities 

January 26, 2012 at 4:44pm

Life moves pretty fast.

This video was uploaded today. I can’t believe I’m about to do this, but I have to quote a YouTube commenter on this one:

YOU DON’T GET TO PLAY WITH OUR HEARTS!

(Source: twitter.com)

2:50pm

One of the exclusive Star Wars movie posters made by the incomparable Olly Moss. They went on sale in late December, 2010, and sold out in minutes.

One of the exclusive Star Wars movie posters made by the incomparable Olly Moss. They went on sale in late December, 2010, and sold out in minutes.

9:42am — Reblogged from merlin

Filed Away for Future Claim Chowder

Filed Away for Future Claim Chowder

(Source: merlin)

January 25, 2012 at 5:05pm

Pride →

David Heinemeier Hansson:

When I switched to Apple back in 2002 after the introduction of OS X, it felt like a renegade position. The world was running Windows and anyone bothering with a Mac was by definition an outsider.

We had to deal with incompatibilities of all kind. There was the ridicule of overpriced shiny white plastic. We were somewhere in between the “first they ignore you” and the “then they laugh at you” state of adoption. But for those of us who endured it, the result was not disillusion but a hardening of the resolve. Macs were (and are) just better. Not just because they were better built or put together, but because Apple was a better company. A braver company. A company that stood for higher ideals. When compared to the empire of Microsoft and the Dells, Sonys of the time, it simply felt like they were more right.

When I looked at that, it seemed like an injustice that Macs and Apple were the odd ones out. Like quality was being held back and barred a chance to shine just because the dominant gorillas in the room had so much power and inertia going for them.

At first glance, a lot of Apple pundits, bloggers, and whatnots appear to be gushing, perhaps even gloating, over yesterday’s financial results. Those verbs may be accurate.

But I see it also as something else: pride. True, it’s been a long time since Apple was actually an underdog, but for those who’ve been telling people for the last ten years that you can in fact right-click on a Mac, it’s a somewhat novel feeling.

(Source: daringfireball.net)

8:37am

Out of thin air. →

How much do music and movie piracy really hurt the U.S. economy? Kal Raustiala and Chris Sprigman set the record straight:

Supporters of stronger intellectual property enforcement — such as those behind the proposed new Stop Online Piracy Act (SOPA) and Protect IP Act (PIPA) bills in Congress — argue that online piracy is a huge problem, one which costs the U.S. economy between $200 and $250 billion per year, and is responsible for the loss of 750,000 American jobs.

These numbers seem truly dire: a $250 billion per year loss would be almost $800 for every man, woman, and child in America. And 750,000 jobs – that’s twice the number of those employed in the entire motion picture industry in 2010.

The good news is that the numbers are wrong — as this post by the Cato Institute’s Julian Sanchez explains. In 2010, the Government Accountability Office released a report noting that these figures “cannot be substantiated or traced back to an underlying data source or methodology,” which is polite government-speak for “these figures were made up out of thin air.”

You don’t say.

January 24, 2012 at 11:57am — Reblogged from theauditory

To achieve great things, two things are needed: a plan, and not quite enough time.

— Leonard Bernstein

To achieve great things, two things are needed: a plan, and not quite enough time.

Leonard Bernstein

(Source: theauditory, via blogthoven)

January 23, 2012 at 10:58pm

The Paper Fox, from a beautiful new iPad book for children by Australian graphic designer Jeremy Kool.

The Paper Fox, from a beautiful new iPad book for children by Australian graphic designer Jeremy Kool.

January 22, 2012 at 7:47pm

Catching up to our future. →

My last post ended on a sad note. But it seems to me that if we want to catch up to the future that’s rapidly outrunning the average American, our education system is a good place to start. There’s always hope.

Nicholas D. Kristof:

To me, the lesson is that while there are no silver bullets to chip away at poverty or improve national competitiveness, improving the ranks of teachers is part of the answer. That’s especially true for needy kids, who often get the weakest teachers. That should be the civil rights scandal of our time.

(Source: twitter.com)

7:35pm — Reblogged from thisistheverge

The truth hurts. →

The New York Times examines the decline of the American manufacturing sector by taking a look at one of our most profitable producers of consumer goods, Apple, Inc.:

Mr. Jobs angrily held up his iPhone, angling it so everyone could see the dozens of tiny scratches marring its plastic screen, according to someone who attended the meeting. He then pulled his keys from his jeans. People will carry this phone in their pocket, he said. People also carry their keys in their pocket. “I won’t sell a product that gets scratched,” he said tensely. The only solution was using unscratchable glass instead. “I want a glass screen, and I want it perfect in six weeks.”

After one executive left that meeting, he booked a flight to Shenzhen, China. If Mr. Jobs wanted perfect, there was nowhere else to go.

cf. (emphasis added):

“We shouldn’t be criticized for using Chinese workers,” a current Apple executive said. “The U.S. has stopped producing people with the skills we need.”

The worst sin to commit during this discourse is oversimplification, but I honestly don’t know if this “problem” is fixable.

(Source: thisistheverge)