Fill image comments fields with part of filename using regex

I want to fill the comments field of image files with a part of the filename
whilst using regex.

All filenames end up with 3 to 4 digits, but because the other part of the filenames
are slightly different, it is impossible to get the files sorted correctly, that is on the
last 4 digits being the seq#.

Question : is this possible??

I might then try and use that field to sorting purposes.

Thanks


not exactly what you wanted, but maybe a solution for your sorting requirement

Custom Column - Custom Text V1.2

Thanks. Have tried to figure this out, am no expert on this, it is a slippery road for me.

Took the latest .osp file (CustomtextColumn v1.2.osp)
renamed .osp to .zip, extracted the file, edit CustomtextColumn v1.2.js under 'numeric id' as follows

name:"Numeric Id", itemProperty: "name", re: /\[(\d{3,4})]/

save, zip, rename to .osp again.

numeric id is not filled, regretfully so.
100% sure I am doing something wrong, but what..?

=

Matter solved with Exiftool: using regex to fill the xpcomment field.

If you want to avoid exif tool
RegExColumns
and add the following line to the config

"Sequence": {"header":"Seq", "inputItemProperty": "name_stem", "regexp":".*[a-zA-Z]([0-9]{3,4})$"}

Thanks!

I know you mean well and I appreciate your help, let there be no doubt about it.

However, I am not familiar with script-stuff.
Can open the .osp (.js) file, view the contents, but eh .. it stops there.
Where exactly I need to insert what exactly.

There is no need to edit the actual script :slight_smile:

Open: Settings/Preferences - Toolbars - Scripts
Drag'n'drop the RegExColumns.osp File to the Scripts window to install it
Select RegExColumns - Configure
Double Click RegExColumns in Edit Configuration Window
Remove everything there, and just past the line from my last Post.

Tried to do so a few times.
Opus states there is already such file, but regretfully it is not visible, not in Opus.

the osp file is in the scripts addins, but within Opus the script panel remains blanc, except for 1 other script.
C:\Users\MyName\AppData\Roaming\GPSoftware\Directory Opus\Script AddIns

=


=

[quote="opw62"]Tried to do so a few times.
Opus states there is already such file, but regretfully it is not visible, not in Opus.

the osp file is in the scripts addins, but within Opus the script panel remains blanc, except for 1 other script.
C:\Users\MyName\AppData\Roaming\GPSoftware\Directory Opus\Script AddIns
[/quote]
hm, ok, seems like a version mismatch.
As I have the latest beta installed and was not sure from which version on the functions I use have been available, the minimum version of the script is set to 11.7.5.
You have now three options:

1. Update your installation to the latest beta

2. update to the latest stable 11.7 and try the attached script version (might work, might not work as I could not test it with 11.7)
RegExColumns.osp (11.3 KB)
3. Stick to your exif solution :slight_smile:

Updated to 11.7.6
Spent the last half hour to try and figure out how this works. I did all steps.

deleted all the samples and pasted your line in the "Edit Value of 'RegExColumns' box.

then what?
What is supposed to be happening then, or what I am supposed to do?

..
later
hm... I updated to the wrong version of Opus maybe?

logfile
RegExColumns.js: ERR: DOpus Version 11.7.5required to run this script!
RegExColumns.js: ERR: DOpus Version 11.7.5required to run this script!

you should now have a new Custom Column (Columns - Script - RegExColumns - Sequence) called "Sequence" that you could add to your lister, that contains the last 3 or 4 digits of your filenames.


"Sequence": {"header":"Seq", "inputItemProperty": "name_stem", "regexp":".*[a-zA-Z]([0-9]{3,4})$"},
"SequenceNum": {"header":"Seq", "inputItemProperty": "name_stem", "regexp":".*[a-zA-Z]([0-9]{3,4})$", "type": "number"}

Ah .. !
I should look there..

Thanks a lot.

It is really wonderful!

=

How to get the seq to be similar to comments (which was filled by exiftool)
I think the regex would read something like : .*(\d{3,4}(-\d)?).(\w{2,4})

SomeFileName-B1-KL057.JPG
SomeFileName-B1-ZW000.JPG
SomeFileName-B1-ZW000-1.JPG
SomeFileName-B1-ZW001.JPG
SomeFileName-B1-ZW002.JPG
SomeFileNameB1-ZW010-1.JPG
SomeFileNameB1-ZW011.JPG
SomeFileNameB1-ZW011-1.JPG
SomeFileNameB1-ZW012.JPG
SomeFileNameB1-ZW013.JPG
SomeFileNameB1-ZW013-1.JPG

I am not sure but I don't think the above regex works. Updated the regex in the script, but no luck.

Any suggestions?

I am not the real RegEx Master but at least it looks like it is working with my test files.

"Sequence": {"header":"Seq", "inputItemProperty": "name_stem", "regexp":".*[a-zA-Z]([0-9]{3,4}[0-9-]{0,2})$"}

Yes, that is it!

Wonderful...

Thank you so much !! :thumbsup:

Really perfect!

Again.. thanks.

would work if you change the "inputItempProperty"

in my example it is set to "name_stem" => Filename without extension

your regex, implies that there is an extension and therefore should use "name" as InputItemProperty.