# Is there a "Lua for Dummies" book?



## PhilBurton (Sep 1, 2016)

I'm beginning to think that I need to write my own plug-in so I can rename image files the way I want to.

My impression is that the Adobe documentation is written for experienced software developers, which I am not.  Back in my college days, I wrote programs in Fortran and PL/1, so I know how programs are supposed to be written. However, I don't know where to start with Lua, about writing plug-inis, the "data model" for metadata, etc.

Are there any good sources?  Any good, clear examples of plug-in code?  

Why is it that code for the plug-ins I've downloaded is not in clear text?  Is that code encrypted?

Phil


----------



## johnbeardy (Sep 1, 2016)

No, your impressions are right, Phil. You'll have to learn the hard way - as I did. The SDK does contain some plugin samples.

BTW, plugins can't rename files in Lr. They can select files in Lr and then rename the files in the operating system - making them missing in Lr.


----------



## Gnits (Sep 1, 2016)

Consider renaming the files before you import them to Lr. Then you can use any language or toolset you are familiar with.

I have written a mini app using Ms Access, which renames the files to my needs prior to import and does a lot of other things as well. 

It gets over two major issues I have with the Lr import.
1. I can preview the files to be imported and summarise by date, so I can select a date range per project ( say I have two shoots on the one card, taken on different dates).
2. I can filter by file type...so I can import only raw or jpg or both or psd or tiff, etc.

The disadvantage of Access is that it does not work on Mac, but it was the easiest toolkit for me to use at the time.

If I was doing the same task now I would consider Python and SQLite....
A. It works on Mac and Windows.
B. Extremely powerful ( and free)


----------



## PhilBurton (Sep 2, 2016)

johnbeardy said:


> No, your impressions are right, Phil. You'll have to learn the hard way - as I did. The SDK does contain some plugin samples.
> 
> BTW, plugins can't rename files in Lr. They can select files in Lr and then rename the files in the operating system - making them missing in Lr.



John,

Thanks.  If I can't do that renaming entirely in Lr, then there is no point (right now) to learn Lua. :(

Phil


----------



## PhilBurton (Sep 2, 2016)

Gnits said:


> Consider renaming the files before you import them to Lr. Then you can use any language or toolset you are familiar with.
> 
> I have written a mini app using Ms Access, which renames the files to my needs prior to import and does a lot of other things as well.
> 
> ...


Gnits,

There are plenty of file rename utilities for Windows, free and not-free.  I want to be able to do a rename inside Lr that is not supported even in the custom menu.

I sort of/kind of/almost know SQL but I would imagine that there are more straightforward ways to do file naming, in Python, as you suggest.  If I wanted to use Python, then I would be looking for a Python for Dummies book.  

Phil


----------



## Victoria Bampton (Sep 2, 2016)

PhilBurton said:


> There are plenty of file rename utilities for Windows, free and not-free.  I want to be able to do a rename inside Lr that is not supported even in the custom menu.



Just in case you're not already aware of it, there's a workaround using one of John's plug-ins: Complex file renaming in Lightroom made simple – thanks to the Search and Replace plug-in – John Beardsworth


----------



## Gnits (Sep 2, 2016)

First of all, I accept completely that you wish to do this exercise inside Lr.



PhilBurton said:


> There are plenty of file rename utilities for Windows, free and not-free.



I have probably bought most of them. I wanted a solution that works for Mac and Windows so that when I am in the field with my Mac I can use exactly the same workflow as at home on my Windows workstation. Also, I did not want a batch file o/s based script, as I wanted to have a preview of the expected results before I committed to the copy process. Being able to filter (in a user friendly way) by date and/or file type was also a need. Also, my mini app creates the folders required in a year/project structure, so all the heavy file handling is done before I import to Lr.

I have been waiting for years for Adobe to add basic improvements to the import process, but after the Adobe 6.2 import disaster I gave up and did it myself. 

*Ref Python.*
I used the Lynda training site to get the basics of Python (and Tkinter for the GUI). A little disappointed with the Lynda experience, but it got me to base camp.  I am also interested if anyone would like to recommend a Python reference / example book.


----------



## PhilBurton (Sep 2, 2016)

Victoria Bampton said:


> Just in case you're not already aware of it, there's a workaround using one of John's plug-ins: Complex file renaming in Lightroom made simple – thanks to the Search and Replace plug-in – John Beardsworth


Yes, I know, and I plan to look at that option.  Thanks.  Right now I'm building out my "plug-in roster" and I expect to use a number of his tools.

Phil


----------



## PhilBurton (Sep 2, 2016)

Gnits said:


> First of all, I accept completely that you wish to do this exercise inside Lr.
> 
> 
> I have been waiting for years for Adobe to add basic improvements to the import process, but after the Adobe 6.2 import disaster I gave up and did it myself.
> ...


Gnits,

I used to know Guido von Rossum, the person who created Python. We both worked at the same Silicon Valley startup company in 2005.  The company got shut down one day by the venture capitalists because it was losing money.  Everyone, everyone, became redundant all at once.  Guido went on to Google, and now I think he is at a different company.  Very smart guy, very down to earth, nice chap.

Phil


----------



## Gnits (Sep 2, 2016)

Phil, thanks for the feedback.  Are you suggesting it is a bad idea to develop my skills further on Python.

While I  am not a fan of Tkinter I can see myself becoming quite fond of Python.  Getting to grips with declaring global variables in functions was/is strange, but will adopt.

I am keen to make myself independent of Access for desktop database stuff and like the way Python and Sqlite are such a comfortable combination. Also like that I can use on Mac and Windows.


----------



## rob211 (Sep 2, 2016)

I take it exiftool couldn't do the job? Depending on what you're trying to do sometimes it's a multi step workflow, like adding something to metadata so that can be used later as part of an export workflow, since Lr might not otherwise be able to generate it (did that with some reverse geocoding stuff in the past). Or doing sequences within directories that are named by date or other criteria so the sequences match, like 2016-09-01_001, etc or Vacation Tues_001, Vacation Wed Night_001.


----------



## johnbeardy (Sep 2, 2016)

Learn Lua, or Python, or use Exiftool for a file naming requirement? If you're having to jump through such hoops to achieve something, Phil, maybe step back and consider if it's really the sensible thing to do.


----------



## Gnits (Sep 2, 2016)

rob211 said:


> I take it exiftool couldn't do the job?



I embedded Exiftool in my code.  I extract the Capture Date, Camera Make, Model and Serial Number. I keep a table within Access where I assign a 1 digit code unique to each camera I use (or Z ) if it is not my camera and use this code in the new Filename.    

For each jpg I check if there is a corresponding raw and vica versa.  I issue a warning if there are jpgs and no equivalent raw files, so I do not delete jpgs by mistake, etc..etc.   My protocol is to get computers to do what they are good at and help me speed up my workflow and catch mistakes before they occur.


----------



## Gnits (Sep 2, 2016)

johnbeardy said:


> Learn Lua, or Python, or use Exiftool for a file naming requirement?



Downloader Pro is good if you are on Windows and has a decent preview (if I can remember correctly).  
Downloader Pro - Download, Organize, Rename Images Photos Canon, Fuji, Minolta, Olympus and Pentax Digital Cameras


Photomechanic provides lots of options, but not a preview before copy (and I did request the feature many times over many years).


----------



## rob211 (Sep 2, 2016)

johnbeardy said:


> Learn Lua, or Python, or use Exiftool for a file naming requirement? If you're having to jump through such hoops to achieve something, Phil, maybe step back and consider if it's really the sensible thing to do.


Yeah, I expect the limitations of storing info in filenames is one reason why the tools don't exist to automate their creation. Not to mention their sidecars if you use RAW and so on.

But sometimes some people look ONLY to the filename for info. An increasingly small number, since everyone on social media knows about other ways to include info, organize by more than filename, ID people, and so on, but still. Some folks I know just get a thumbdrive (or CD!) of exported jpegs and expect the filename to not only tell them what they're looking at but also preserve the sequence. I'm not gonna turn my whole photo organization upset down to appease the lowest common denominator, and so I've stopped doing anything but adding captions and such (which are SO much more useful) and instructing them instead to use a viewer. So far they haven't rebelled, but YMMV.

I dunno if that's Phil's problem but it's one I've had. And of course one must consider what to do with the complex named files. Whether that facilitates finding, sorting and filtering them, backups, and so on. I suspect, again, that this is the reason why files that got shared as early digital photos did evolved to contain standard metadata rather than attempting to cram all the press info into a filename. Or a separate file.


----------



## johnbeardy (Sep 3, 2016)

rob211 said:


> But sometimes some people look ONLY to the filename for info. An increasingly small number, since everyone on social media knows about other ways to include info, organize by more than filename, ID people, and so on, but still. Some folks I know just get a thumbdrive (or CD!) of exported jpegs and expect the filename to not only tell them what they're looking at but also preserve the sequence. I'm not gonna turn my whole photo organization upset down to appease the lowest common denominator, and so I've stopped doing anything but adding captions and such (which are SO much more useful) and instructing them instead to use a viewer. So far they haven't rebelled, but YMMV.
> 
> I dunno if that's Phil's problem but it's one I've had. And of course one must consider what to do with the complex named files. Whether that facilitates finding, sorting and filtering them, backups, and so on. I suspect, again, that this is the reason why files that got shared as early digital photos did evolved to contain standard metadata rather than attempting to cram all the press info into a filename. Or a separate file.



The big mistake is to allow _someone else's requirements_ to drive _your_ filenaming practice and good organization. After all, if those social media folk need the filename to be stuffed full of info like people's names etc, that doesn't mean we need to jump through hoops renaming our originals and potentially screwing up Lightroom. We can - we should - add all that information to the exported file.


----------



## PhilBurton (Sep 4, 2016)

johnbeardy said:


> The big mistake is to allow _someone else's requirements_ to drive _your_ filenaming practice and good organization. After all, if those social media folk need the filename to be stuffed full of info like people's names etc, that doesn't mean we need to jump through hoops renaming our originals and potentially screwing up Lightroom. We can - we should - add all that information to the exported file.


My goal of naming files according to date/time and sequence goes back to my film photography days.  Of course, with digital photography, that approach is way easier.

I completely concur with coming up with our own preferred naming scheme.  There is so much "advice" out there which is nothing more than, "Do it my way, because it's the best way to do something."  Bah, humbug!

Phil


----------



## johnbeardy (Sep 4, 2016)

Equally, Phil, there is good and poor filenaming (not judging whatever yours is), and bad practice often hides behind "it's always worked for me", "YMMV" etc.

John


----------



## Gnits (Sep 4, 2016)

My motivation for renaming is to avoid duplicate images, especially when using multiple similar cameras in the same project folder.  

Once I had my renaming wrapped in a piece of code I was easily able to add useful validation and workflow features and options missing in the Lr Import dialogue.

Everyone things their renaming schema is the best, but usually people are trying to solve problems as they perceive their particular challenge.


----------



## johnbeardy (Sep 4, 2016)

A criterion such as avoiding the possibility of duplication is one badge of what I'd consider a good naming scheme. As an indicator of something bad, I'd point to the inclusion of text for months ("September").


----------



## Jknights (Sep 4, 2016)

johnbeardy said:


> A criterion such as avoiding the possibility of duplication is one badge of what I'd consider a good naming scheme. As an indicator of something bad, I'd point to the inclusion of text for months ("September").



I used to provide consultancy in Document Management for a large international pharmaceutical company.  They have tens/hundreds of millions of records of compounds, tests, test results, etc., so rapid searching is essential.

I agree with John Beardy that the use of (meaningful) text in an index (filename) is not good.
One of the best practices is to *not* use meaningful codes.
You also need to decide what you need to use your code for.  Is it sorting/ordering or some other facility?.   Hint: Sequential numbers are very good at being unique  

However I wont suggest all sort of design patterns on you as I am sure you are well able to choose what suits you best.


----------



## rob211 (Sep 4, 2016)

I gave up file renaming years ago (part of that had to do with work issues around storing files; changing filenames was perceived as altering the file and a no-no). Note there's a difference between naming a file and naming a picture (again, another reason IPTC metadata exists). And once it got so easy and quick to search photo metadata even outside of photo applications (as in Mac's Spotlight, for example) it was game over. I have tons of duplicate names for old photos (like img_0001) but it doesn't matter at all, except in the case of some ancient ones without exif data where the original filename preserves sequence since there's no date/time stamp. Coming from film I came to view the filename as akin to the number of the negative or slide; not to the title of the image. So I guess I was influenced by that tradition as well, although it took me a bit to decide to do that rather than rename.

I suppose since I use multiple cameras at times on the same day that this could result in the same file name, but when I got the cameras I set up the camera-generated sequence to avoid that (although it sometimes took care of itself) and I've never had reason to do anything else. The only info I want in the name is the sequence. But some people's workflow does rely on more complex filenames, and I feel for those folks since filenames are rather more difficult to work with (haven't we even had issues with Lr and case sensitive file/folder systems, eg?).

Also, I wind up with images that come from others and with backups that have the original filenames; if I rename the ones I'm using in Lr then it gets to be annoying to reference the same image when I'm corresponding with the creator of the image, or when trying to find the file from a backup. Something to consider if you have the same needs.


----------



## Gnits (Sep 4, 2016)

rob211 said:


> Also, I wind up with images that come from others



Same here... many are from Canon cameras.... so nearly guaranteed to have the same file name as some of my early images.


----------



## PhilBurton (Sep 4, 2016)

Gnits said:


> My motivation for renaming is to avoid duplicate images, especially when using multiple similar cameras in the same project folder.
> 
> Once I had my renaming wrapped in a piece of code I was easily able to add useful validation and workflow features and options missing in the Lr Import dialogue.
> 
> Everyone things their renaming schema is the best, but usually people are trying to solve problems as they perceive their particular challenge.


I know some people who include subject information in their filenames becuase this approach allows them to avoid a full-on cataloging process.  It addresses their needs and who am I to criticize.

Phil


----------



## johnbeardy (Sep 4, 2016)

Well, you should criticise if adding text information crosses into bad practice. For example, if the text info comes before the date or a sequential number, you lose the ability to sort chronologically. Or non-alpha characters always cause problems somewhere down the line. I've no problem with text information and I'd advocate it because it is convenient, but it should be brief and only added to a good filename.


----------



## PhilBurton (Sep 1, 2016)

I'm beginning to think that I need to write my own plug-in so I can rename image files the way I want to.

My impression is that the Adobe documentation is written for experienced software developers, which I am not.  Back in my college days, I wrote programs in Fortran and PL/1, so I know how programs are supposed to be written. However, I don't know where to start with Lua, about writing plug-inis, the "data model" for metadata, etc.

Are there any good sources?  Any good, clear examples of plug-in code?  

Why is it that code for the plug-ins I've downloaded is not in clear text?  Is that code encrypted?

Phil


----------



## PhilBurton (Sep 4, 2016)

johnbeardy said:


> Well, you should criticise if adding text information crosses into bad practice. For example, if the text info comes before the date or a sequential number, you lose the ability to sort chronologically. Or non-alpha characters always cause problems somewhere down the line. I've no problem with text information and I'd advocate it because it is convenient, but it should be brief and only added to a good filename.


The examples I have in mind are open to criticism but, but, but for the people who have devised these systems, they "work" at least for initial "cataloging."  However, for searching and sorting, these systems are pretty well useless.  And they also suffer from issues like the lack of a controlled vocabulary, etc.  

That all said, let's not forget that Lightroom users are on average both sophisticated photographers and savvy computer users.  

Phil


----------



## johnbeardy (Sep 4, 2016)

PhilBurton said:


> That all said, let's not forget that Lightroom users are on average both sophisticated photographers and savvy computer users.



You shouldn't assume that at all. Some certainly are both, many are one or the other, and many lie at the low end of both spectrums. They are generally "aspirational", which is a different scale entirely.


----------



## PhilBurton (Sep 4, 2016)

johnbeardy said:


> You shouldn't assume that at all. Some certainly are both, many are one or the other, and many lie at the low end of both spectrums. They are generally "aspirational", which is a different scale entirely.


Good point.  However, the people I have in mind with their subject-matter-based file names aren't aspirational.  Just short-sighted or generally not very computer-literate.

Phil


----------

