GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Column - Custom Text and Regexp

Another small addition I'm finding useful:
When creating a naming convention with a view of parsing long file names into regex columns, one risk is to run out of characters for the file name (the Windows max for path + file name is 260).

The following tweak adds columns so you can keep track of the length of file names.

In the column definitions:

  { name:"c.namelen",
    // this column give you the length of the file name

  { name:"c.charsleft",
    // this column give you the number of chars still available to use in the path + file name
    // Windows imposes a 260 maximum length for the Path+Filename

// no need for a custom column for the length of file + pathname as that column is available under General / Path length

In OnCustomText:

  // filename length column?
  if ( == 'c.namelen') {
    scriptColData.value =

  // characters left column?
  else if ( == 'c.charsleft') {
    // Windows imposes a 260 maximum length for the Path+Filename    
    // how many more chars available in the path + filename? 
    var PathLength = new String(scriptColData.item.realpath).length
    scriptColData.value = (260-PathLength).toString()

  else { // it's a regex column
    // etc

There's a built-in Path Length column which should be better/quicker for that one of the three. I think the other two are new & useful, though.

Ahhh, indeed! I missed that. Removed it. Thank you. :slight_smile:

Thanks for all the feedback @playful and @Miran. Both your scripts were good reading.
A new version V1.5 has been created that uses a dialog to configure the columns. See First post.

Easy to use and very useful.
Thank you.

1 Like

Updated to version 1.5.2. This added support for passing in extend item properties, (I.E. as the source input for the regexp to execute against.

This idea and code is thanks to @andersonnnunes, who posted the idea here.

1 Like

Updated to version 1.5.5.

  • fixed grouping, the nogroup was always being set to true.

As reported here

Oh so the problem was RegEx and not Directory Opus.
I confirm it's fixed. Thanks

Well technically not the RegExp. The RegExp that special string we created to extract parts of the file name. The issue was in this custom column script. I didnt get the grouping right, and was disabling grouping on all the columns it created. Dopus was doing exactly as asked.
Thanks for confirming it's fixed.

Hi @wowbagger

I have just tried your script. Very nice! Two nits to report.

  1. The Apply button text reads "Appy Changes" instead of "Apply Changes".
  2. If I modify a column label and press apply the change is not shown. The change is made but doesn't show up until the column is closed and reopened.

Regards, AB

Now for a real question. I have created a regexp to isolate an identifier in the filename with the format XX followed by 3 digits followed by zero or more suffix letters. This identifier can appear anywhere in the name and is not necessarily present.

I am using: (.\*)(\bXX\d{3}[\w]*)(.\*) and my output criterion is $2. It works fine when there is a match for $2 but when there is no match the result is the whole original string. e.g.

Some text XX123a some description.txt ==> XX123a
XXxxx some description.txt ==> XXxxx some description

I would like a mismatch to return an empty string. I am no expert so my regexp may well be incorrect for what I want and of course this behaviour may be working as designed. Advice welcomed....

Regards, AB

hi @aussieboykie.

I don't know if I would call that a bug of a feature ;).
I updated the script to first check if the regexp is a match before preforming the replace. Otherwise the replace method would return the the input as there was nothing to replace. This seems better.

I don't know if you can force the column to reload. The script only reloads the column values when you press apply.

Updated to version 1.5.6

  • Only return a value if the regexp is a match.
  • Fixed typo in the Apply button

Good idea @aussieboykie this has been added. Thanks for the suggestion.

Updated to version 1.6

  • When updating a column, if that column is on a tab, it will removed and re-added. This does not work that well when renaming a column.
  • Added an Add to Lister button to the Dialog
  • Added a Remove from Lister button to the Dialog

Thank you so much for your work, @wowbagger
That is a great Script Add-in.

I made a new version (1.7) on your behalf, and I would be glad if you check it.

Changelog: (code commented with "By @asakka")

  • Added a checkbox in column settings, when enabled in case of "graph" or "igraph" types, the script make the graph relative to the largest value of all items inside current folder. The performance of the script is great, as I check for the max value only once and store it in script variable as long as the folder path is not changed.
  • Added three sample columns to demonstrate the "Graph Related" feature.
  • Added a button in the dialog to restore the sample columns

RegExpColumns.osp (34.6 KB)

1 Like

Thanks for your input @asakka.
With DOpus 12.7.3 we now have relative columns, without the need to pre-scan the folders. I have also looked at the multiple column calculations issue your raised. Let me know what you think.

Updated to version 1.8

1 Like

Added more support for 12.7.3

Updated to version 1.9

  • Added support for column types graphrel0, igraphrel0 and percentrel0.
  • Added support for graph_colors, graph_colors2 and graph_threshold column values.
  • Improved for UI for graph, igraph and percent columns.

Can you check this?
RegExp columns seem to be the problem

Updated to version 1.12

  • Added support for text column formatting. Allows for extracted value to be case formatted before displaying in the column.
    • Supported formatting - upper, lower and title

I recall someone asking to be able to format the name column, but I can't find that post now. Still I thought this would be a handy addition to the script.

1 Like

Updated to version 1.13

  • Added support for targeting the file contents. This can be somewhat expensive and would benefit from combining with a file filter. I do try to only read each file once regardless of how many columns are selected.

I actually added this a while back but remove it due to some performance issues, but those were resolved around version 1.8. I forgot to add it back in.

Updated to version 1.13

A little flaw: initData.version = "1.12"

1 Like