.
Lightroom “Run Any Command” Piglet

This page describes my “Run Any Command” Lightroom Piglet, which allows the technically savvy user to run any command with each image exported via one of my Lightroom export plugins ( Zenfolio  ·  SmugMug  ·  Flickr  ·  Picasa Web ), or via any export plugin that uses my piglet infrastructure.

This “Run Any Command” piglet is already included with my export plugins since January 22, 2008. However, if you'd like to use the piglet with a different plugin, you can download AnyCommand-20080206.5.zip. Version history is shown below.

Even though the piglet is included with my plugins, like all piglets, it must be enabled from the Piglet Manager before it can be used the first time. As described on the piglet page, you can bring up the Piglet Manager from the bottom-most section of the export dialog of any of my export plugins. You then enable the piglet:

After restarting Lightroom, you'll have a section in the export dialog that allows you to enter a command. Here's what it might look like with a command already entered:

Later, during the actual export, the command is run after Lightroom generates each export file, but before the plugin does other things with the file (such as uploading the image to Flickr, in the case of my Export-to-Flickr plugin).

Command Metasequences

Within the text entered for the command, special sequences are recognized and replaced by image-specific values with each execution:

SequenceReplaced ByAdded In
{FILE}The name of the exported image file, with full path20080123.2
{file}The name of the exported image file, without the leading path20080123.2
{NAME}The name of the exported image file, with full path, but without the file extension20080123.2
{name}The name of the exported image file, without the leading path and without the file extension20080123.2
{folder}Full path of the (likely temporary) folder that the exported file lies in20080130.4
{FOLDER}Full path of the (likely temporary) folder that the exported file was originally exported to.
This is the same as {folder} unless the plugin or another piglet has changed the filename
20080130.4
{EXPORTED}Full path of the file as originally exported.
This is the same as {FILE} unless the plugin or another piglet has changed the filename
20080130.4
{exported}Name of the file file as originally exported, without path.
This is the same as {file} unless the plugin or another piglet has changed the filename
20080130.4
{home}Full path of the user-dependent “home” folder20080130.4
{desktop}Full path of the user-dependent “Desktop” folder20080130.4
{pictures}Full path of the user-dependent picture folder (“My Pictures” or “Pictures”)20080130.4
{documents}Full path of the user-dependent document folder (“My Documents” or “Documents”)20080130.4
{temp}Full path of a system-dependent temporary folder20080130.4

Be warned that you must be very careful about where to quote items: anything that has a space or other special shell variables must be quoted, but exactly what must be quoted, when, and with what kind of quotes is dependent on the operating system. It's fairly straightforward on a Mac: using single quotes will almost always be okay, double quotes probably okay in most cases as well. On Windows, use double quotes and cross your fingers.

As an example, you'll notice that in the screenshot above (which was made on Windows XP), I've quoted the command name (the full path to my exiftool install) because the path has a space in the name (in “Program Files”). I've also quoted {FILE} because the image filename may have a space in it as well (e.g. “Documents and Settings”).

ExifTool

This example command uses Phil Harvey's most-excellent exiftool command to strip out the thumbnail that Lightroom embeds in its exported images. The command is:

"C:\Program Files\ExifTool\exiftool.exe"    -overwrite_original    -Photoshop:ALL=    "{FILE}"

Using other permutations of arguments, you can do a lot with your images with exiftool and this piglet. It's with exiftool in mind that Mark Sirota first suggested this piglet to me, at which point I thought “duh, why didn't I think of that?” and, so, now here it is.

Version History

20080206.5Allowed the codes like {FILE} and {name} to be translated.
20080130.4Added support for {folder}, {FOLDER}, {exported} {EXPORTED}, {home}, {desktop}, {pictures}, {documents}, and {temp}. Thanks to mariane for the ideas.
20080128.3Tidied up some mistakes in the translation hooks. Interested in doing the translations for my plugins for your favorite language? It's a difficult and thankless job, but you earn good karma for giving to the greater community. If interested, please contact me (jfriedl‍@‍yahoo.com).
20080124.2Minor changes
20080122.1Initial release '

Comments so far....

Thanks, Jeffrey — with the combination of the Run Any Command and LR/Mogrify piglets and the Flickr export plugin, I’m looking forward to reinventing my post-Lightroom workflow!

— comment by Mark Sirota on January 23rd, 2008 at 12:43am JST (3 months ago) comment permalink

—- Google translation —-

Hi,

Some LOC-Strings are not unique. This causes problems when
translating “Run Any Command” piglet.

LOC-Strings:

$$$/AnyCommand/file=Like {file}, but with the extension removed”
$$$/AnyCommand/file=The name of the image file, without path; wrap in quotes to be safe”

Greetings from Germany

by mariane

This error (and a few others) are fixed in the most recent versions. Thanks for the report. If you’re doing a translation for my plugins, I’d love to be able to release it to everyone. Please contact me if you’d like to share it! —Jeffrey

— comment by mariane on January 27th, 2008 at 7:31am JST (3 months ago) comment permalink

Hi,

Proposal to routine: “startOfOneRender(PIGLET_INFO)”.
An extension to standard paths: {home}, {temp}, {desktop}, {pictures}, {documents}

local function startOfOneRender(PIGLET_INFO)
...
... function (item)
if ...
...
elseif item == 'home' then
return LrPathUtils.getStandardFilePath('home')
elseif item == 'temp' then
return LrPathUtils.getStandardFilePath('temp')
elseif item == 'desktop' then
return LrPathUtils.getStandardFilePath('desktop')
elseif item == 'pictures' then
return LrPathUtils.getStandardFilePath('pictures')
elseif item == 'documents' then
return LrPathUtils.getStandardFilePath('documents')
else
return nil
end
...

—————————————————

I would like a specific sequences, which the original name of the image than content.
I do not like this in Lua will be programmed.

img_1234.cr2 –> LR –> LR/TRansporter + Mogrify.piglet -> img_1234.jpg –>

–> RunAndCommand.piglet -> {file} –> img_1234.jpg
–> RunAndCommand.piglet -> {FILE} –> e:\export\website\images\img_1234.jpg
–> RunAndCommand.piglet -> {original} –> img_1234.cr2
–> RunAndCommand.piglet -> {ORIGINAL} –> f:\photos\Canon\1000\img_1234.cr2

Greetings from Germany

by mariane
– This text has translated google, I am innocent :)

Thank you for the good ideas, Mariane. I just pushed .4 to add these. Unfortunately, the plugin/piglet does not have access to the original path of the file (where it is within Lightroom), so I couldn’t add that one. —Jeffrey

— comment by mariane on January 28th, 2008 at 10:09am JST (3 months ago) comment permalink

Similar to mariane, I could use a way to sync the current state of my RAW files into JPEG files that could be used by outside software such as that for photobooks, etc. I think you have the tools since it appears that you can capture the file location of the original file before the export. Two approaches:

1) I could select an upper level folder and then “Ctrl A” to select all pictures thereunder. After exporting to a fixed “temp” directory, a command could move the file (faster than copy) to a new mirror location that uses the file structure of the original file but changes it slightly so the browser knows which are the RAW and which are the JPEGS. If the raw files are in the “c:\pictures\RAW\January\” directory, when exported, the JPEG equiv would show up in the “c:\pictures\JPG\January” directory with the same name but a “JPG” extension.

2) Alternatively, the JPEGs can simply live alongside the RAW files so instead of moving them to a mirror directory, they can be moved to the original directory. LR can be set to ignore them so they will not clutter the view.

It may be that a combination of your plug-ins and other command-line software can accomplish this in which case I would be greatful.

From other posts, it appears that this is an item that might show up in a future release.

Thanks!

JW

— comment by JW Stephenson on January 30th, 2008 at 1:38pm JST (3 months ago) comment permalink

The old-fashioned way of doing things (pre your plugin) made the IPTC Location data go into the keywords. I didn’t mind that at all (I know FlickR has geo-facilities), but it was nice to have the location (country, city,…) go into the tags. Any possibility of fitting that in?

— comment by Mike on February 9th, 2008 at 5:54pm JST (3 months ago) comment permalink

Hello Jeffrey,
I found your blog while searching for a way to see the Canon auto focus frame data in Lightroom. You have some great info and photos here.

Canon’s ImageBrowser application allows you to see which of the auto focus sensors was the focal point.

Is there a way to create a Lightroom plugin or piglet which will allow you to see these af points in the develop module? Has anyone done this already?

Thanks for a very informative blog. And thanks for the Exif Viewer, it’s awesome!

Best regards,

-Joe Azzato

— comment by Joe Azzato on February 10th, 2008 at 4:44pm JST (3 months ago) comment permalink

Hello Jeffrey,

fine idea, thanks for implementing this!

As Mariane already suggested: Do you know any way to get the original location of an image out of Lightroom? Is there a way to get a list of filenames for images in a Collection?

No, not with 1.3 —Jeffrey

Thanks and best regards,
Georg

— comment by Georg on February 21st, 2008 at 6:38am JST (2 months ago) comment permalink

Hi
thanks for your amazing job

i would love to have an export plugins to export raw files in my hardisk
why don’t make a simple command line for exiftool , a simple command line
with source , destination and a blank space where we can add exiftool commands

for example somebody could be happy to erase own serial number or name or other private info , with exiftool is very easy

or sombody would like to eport files with a metatada hierarchy, exiftool could too

it would be really very appraised, estimated a SIMPLE plugins (maybe with not a short limit for the free version)

thanks for your job and for your effort

Tim Armes’ LR/Mogrify plugin will do what you want. It supports the AnyCommand piglet, so you can just turn off all the Mogrify features to take advantage of the AnyCommand aspect of it to run exiftool on your images. —Jeffrey

— comment by mantra on February 26th, 2008 at 3:05am JST (2 months ago) comment permalink
Leave a comment...

More or less plain text — see below for allowed markup

You can use the following tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>