PDA

View Full Version : Feature Request: Token for renaming from Dir



Jeffrey
June 17th, 2008, 12:46 PM
I could really use a token set that I could use to rename my images based upon the first word of the directory name. Very similar to the job code {JC_fw}.

My layout is like to this.

GM1 Red vs Green
GM2 Maroon vs Turquoise

All I need in the name of the file is the GM1 or GM2 to locate the file. The rest is so the folks reading and ordering can locate their game.

Renaming at download isn't sufficient, as I sometimes need to break a game down to separate directories because of size considerations ie first half and second half.

GM1A Red vs Green 1st half
GM1B Red vs Green 2nd half

Just being able to rename the files once separated into the directories would be a lot easier to do vs anything else I can figure out.

Even if we could choose the number of characters from the name, that would work as well.

Thanks for listening.

Jeffrey

DavidB
June 17th, 2008, 01:50 PM
Jeffrey

One approach you could consider is using your initial code in both the both the directory name and the file name at download (which I assume you are doing in DL Pro). So both your directory and your file names will begin GM1, GM2A or whatever.

When you come to rename in BB Pro (which I also assume you are doing, as you posted to this forum), you can use the token %[1-3] to extract the first 3 characters (GM1 or whatever) from the original file name.

However, if Chris thought it would be useful to follow up your request, he might wish to consider a set of (say) %$[...] and %$![...] tokens which work with the 'container' directory name in the same way as %[...] and %![...] work with the file name.

Hope this helps.

David

Chris Breeze
June 18th, 2008, 08:18 AM
You could do this in two stages:
1) Batch rename to prefix the filenames with the directory name: @dirName@%o
2) Batch rename extracting the first three characters of the filename followed by the last 8, say. e.g. %[1-3] _%[-8]

Alternatively you could store the prefix in one of the fields of the IPTC/XMP data when downloading the images using Downloader Pro and then batch rename in BBPro. e.g. if the prefix is saved in the object name field you could batch rename in BBPro using @IPTC_objectName@_%o

DavidB
June 18th, 2008, 12:50 PM
... Alternatively you could store the prefix in one of the fields of the IPTC/XMP data when downloading the images using Downloader Pro and then batch rename in BBPro. e.g. if the prefix is saved in the object name field you could batch rename in BBPro using @IPTC_objectName@_%o
Of the options mentioned, this is, I believe, the best, and I'm sorry I didn't think of it. I do something similar with the folder number. The big advantages of this approach are (1) that once set up in DL Pro it's almost automatic and (2) that the data is preserved in the image file.

The one caution is that you have to watch out for applications which trash or do strange things to IPTC data; even Photoshop can spring surprises. If you always edit files to a copy, rather than overwrite the original (best practice in any case), BB Pro can copy the EXIF and IPTC data to the new file, at least if it is a JPEG or (with limitations) a TIFF.

Jeffrey
June 18th, 2008, 02:01 PM
When you come to rename in BB Pro (which I also assume you are doing, as you posted to this forum), you can use the token %[1-3] to extract the first 3 characters (GM1 or whatever) from the original file name.

However, if Chris thought it would be useful to follow up your request, he might wish to consider a set of (say) %$[...] and %$![...] tokens which work with the 'container' directory name in the same way as %[...] and %![...] work with the file name.



The "identifier" is not always 3 letters, even at the same event, that is why I was suggesting the way the job code is used {JC_fw}. It also would be familiar, just a different piece of information taken from somewhere else.

I have written several scripts that take care of some of the short comings I have found with DLpro and BBpro, I just can not figure out a good solution to this one other than have the token be native.

One of my favorite scripts I wrote was to batch rename recursively under an events name. I sometimes forget to manually rename or sometimes we have a lot of sub-events to go out at same time, and it is faster to have an automatic routine that renames everything for sure.

Just asking.

Jeffrey

DavidB
June 18th, 2008, 08:44 PM
The "identifier" is not always 3 letters, even at the same event, that is why I was suggesting the way the job code is used {JC_fw}. It also would be familiar, just a different piece of information taken from somewhere else.
I must admit that I didn't quite understand the analogy with the job code. Presumably, you enter that manually (is that what you mean by 'natively'?) for each download or group of downloads. You can of course have both the job code and the IPTC dialogues come up on starting DL Pro; you're still entering the data manually, but you get a clear reminder so to do. With your code entered in IPTC, everything goes from there as Chris suggested.


I have written several scripts that take care of some of the short comings I have found with DLpro and BBpro, I just can not figure out a good solution to this one other than have the token be native.
In fairness, what you are overcoming are limitations rather than 'shortcomings'; one person's shortcoming is someone else's feature ...


Just asking
Quite so. If you don't ask, you don't get.

Jeffrey
June 25th, 2008, 01:23 PM
In fairness, what you are overcoming are limitations rather than 'shortcomings'; one person's shortcoming is someone else's feature ...


To me they are shortcomings in that it falls short of what I need. It is not a slam.

And thank you Chris, love and use both DLP and BBP, but none of your suggestions was able to work for my situation, hence the request for the similar token as the JC_fw but instead of the JC, use part of the name in the directory.

Here is the last effort to make it sound reasonable.

I just was at an event this past weekend. One photographer shot two games on the same card. There was some mixing due to a slight overlap.

I downloaded the one card, using DLP using the job code for the first game. GM1 Now all images are named with the first games name.

I separate the games into two separate folders. Now the name of the files are wrong for the second game. The files names would also be wrong if I further separated either game to further break them down. I need a slicker way of renaming.

Both suggestions by Chris do not work unless I make the directory name only GM2. If I used GM2 Red vs White, my new file names would be way too long, ie GM2 Red vs White - 1234.jpg

Little more work and thinking on my part, but if I didn't mind working harder, I wouldn't be using Chris' software in the first place. Every second counts.

I do also add an identifier to the end of my file name, GM2-1234 GBAYA jun 2008. So using just the o% token doesn't work either.

So again, if at all possible, a token that extracts part of the directory name for use in batch renaming the image files is what I am asking for.

Thanks again for all the other great features.

Jeffrey

Chris Breeze
June 26th, 2008, 08:21 AM
I'm sorry but I don't think adding a token to extract the first word of directory is a good idea. It is just too specialized and if it was added what about the myriad other combinations of first word/last word etc. for all the other possible elements?

The underlying problem is caused by overlapping jobs on the same card and this is always going to require some manual intervention.

DavidB
June 26th, 2008, 04:38 PM
I'm sorry but I don't think adding a token to extract the first word of directory is a good idea. It is just too specialized and if it was added what about the myriad other combinations of first word/last word etc. for all the other possible elements?
I know that you're the gaffer, Chris, but I respectfully disagree. I thought that Jeffrey's suggestion would be a natural extension of the renaming facilities in BB Pro. It is not uncommon for elements in the file name to be present also in the folder name, as this can provide an audit trail if files are moved or copied elsewhere. And, if you can deal with file names using the %[] and %![] tokens, you can surely deal with folder names in the same way, without any first word/last word issues.

That said, what would be really nice would be a generalised sub-string function in BB Pro that would work with any token. Would that be in the art of the possible?


The underlying problem is caused by overlapping jobs on the same card and this is always going to require some manual intervention.
This I do agree with. And I also think that you're right to suggest that the problem is best solved in DL Pro, by including the relevant identifier as IPTC data. This requires separate downloading of (in Jeffrey's case) data from different games, but that's not necessarily a bad thing, even if it does add another step or two to the process. If you have identified the misplaced images at the download stage, you are better placed to deal with them later on.

David

Chris Breeze
June 27th, 2008, 07:58 AM
A more generalised method of extracting parts of tokens makes more sense than special cases for individual tokens. I've got a few ideas on how to do this might be done and will experiment when I get time.

Jeffrey
June 27th, 2008, 12:21 PM
A more generalised method of extracting parts of tokens makes more sense than special cases for individual tokens. I've got a few ideas on how to do this might be done and will experiment when I get time.

It doesn't have to be the first word or last word as the JC code does. Just a way to extract some part of the directory name. Then it is up to us how to use it and perhaps alter our work flow.

I agree as far as the situation of two "jobs" on one card, but I do action photography, and action doesn't always fit nicely into separate jobs (cards) and we have to work with what we get.

All I am asking is for a way to make the situation easier to deal with when the situation occurs. Which is the exact reason I use Chris' software in the first place!

Hopefully you get some time soon.

Jeffrey

DavidB
June 27th, 2008, 07:40 PM
A more generalised method of extracting parts of tokens makes more sense than special cases for individual tokens. I've got a few ideas on how to do this might be done and will experiment when I get time.
This would be very helpful; thank you, Chris. Something like the old BASIC substring function - along the lines of %$(%o[n-m]) perhaps - would be ideal.

To meet Jeffrey's point, you'd still need a counterpart of %o (%O?) to return the name of the folder containing the image. As I said in my last, I don't think that is an unduly esoteric idea.

Chris Breeze
June 30th, 2008, 12:09 PM
I did a few experiments on Friday and came up with the following:
{left,n,str} - extracts the left n chars from str
{mid,n,m,str} - extracts m chars from str starting from char n
{right,n,str} - extracts the right most n chars from str
{first,str} - extracts the first 'word' in str
{last,str} - extracts the last 'word' in str

str can be any string or token which doesn't contain { or }. A 'word' is defined as one or more alphanumeric characters

e.g. {first,@dirName@} would extract the first word from the directory name

Dan_Honemann
June 30th, 2008, 03:36 PM
I did a few experiments on Friday and came up with the following:
{left,n,str} - extracts the left n chars from str
{mid,n,m,str} - extracts m chars from str starting from char n
{right,n,str} - extracts the right most n chars from str
{first,str} - extracts the first 'word' in str
{last,str} - extracts the last 'word' in str

str can be any string or token which doesn't contain { or }. A 'word' is defined as one or more alphanumeric characters

e.g. {first,@dirName@} would extract the first word from the directory name

Sounds good, Chris. Even more useful, however, would be:

{idx,str,delim,dir}

... where idx would be the position (or index) number of the word desired within the string, str is the string, delim is the delimiter (which could default to a space, but could of course be defined as any single char), and dir defines whether to count from the left or from the right of the string (defaults to left); thus:

{1,@dirName@}

returns the same string as your {first,@dirName} example above, while:

{1,@dirName@," ",R}

returns the last word in the directory name, and:

{3,@dirName@,"-",L}

returns the 3rd string delimited by a hyphen in the directory name, etc.

Dan

Chris Breeze
July 1st, 2008, 09:06 AM
To keep things simple and also avoid performance problems it expands all the tokens first and then processes the substring functions. This means the string needs to be the last argument otherwise it will cause problems if the string is a token containing commas. A string containing } will also cause problems, but hopefully this is less likely than strings containing commas.

It's also a balance between functionality and ease of use. The most flexible way to do it would be to have full regular expression processing like Perl but this would be too difficult for people who aren't familiar with programming to use.

I'm planning to make the substring tokens available anywhere that the @tokens@ are used which means you can also use them in HTML templates, when adding IPTC data, in BBPro's captions etc.

DavidB
July 1st, 2008, 05:42 PM
I'm planning to make the substring tokens available anywhere that the @tokens@ are used which means you can also use them in HTML templates, when adding IPTC data, in BBPro's captions etc.
This is really good news; thank you, Chris. Also, for what it's worth, I found your proposed syntax much easier to get my head round than the suggested alternative.