Columns: No Brackets, Highest Number, Filtered Name

Requires Directory Opus 11.8 or higher
As usual, no guarantees and so on, but it works for me.

Columns:

  • NoBrackets: Filename without prefixing brackets.

  • HighestNumber: Display a folder's highest prefixing number.

    In other words, if you have the files 01.txt, 02.txt, 03.txt then the column would
    display 03 for that folder.

    If recursive is true, check in subfolders too.

    Files are excluded from consideration if they match one of the filespecs in exclusionFilter.

  • FilteredName: Filename filtered according to regexFilters.

    Each regex/JSON line operates on the result of the previous.

    Operates on filename including its extension.

    Common:

    Can use {flags:options} at the beginning of a line to set regex flags. Valid 'options' are: g, i and m. They can be combined.

    If you write {flags:} it disables default flags, making it replace only the first case-sensitive match.

    Default flags: i (case-INsensitive)

    Can use regex comments inside the regexes, in other words these: (?# text here)

    A line can be prefixed by :: to comment out the entire line.

    Regular Expressions:

    Write regexes like you normally would, one per line.

    All matched text will be removed.

    JSON:

    If the line, after removing {flags:} and regex comments, contains " as its first character, treat the rest of the LINE as json (no need for {}).

    You can specify a replacement text (allows $0..$n, and all the others).

    All backslashes \ must be doubled \\ for JSON, in addition to what JScript itself needs. For example:

    • Literal backslash: \\\\
    • Quote: \\\"
    • \s\w = \\s\\w.

    JSON Properties:

    regex = regular expression
    replace = text to replace with (default: remove matched text)
    flags = regex flags (default: i). Tries to use {flags:} when unavailable.

    This is how a JSON line should look (only the regex property is required):

    "regex":"yourregexhere","replace":"yourreplacementhere","flags":"yourflagshere"
    "regex":"yourregexhere","replace":"yourreplacementhere"
    "regex":"yourregexhere"
    

Examples:

If you use the 3 filters below and the filename is...

[Test] [Test2] The text displayed [028a532b].txt

...then the displayed filename will be:

text displayed, The.txt.

(?# Remove initial brackets)^(?:[\s_-]*\[[^\]]+\][\s_-]*)+
(?# Remove CRC)\s*[[_({-][0-9A-F]{8}(?:[_-]?$|[\])_}-])
(?# Place The at the end, but before extension. Use JSON)"regex":"^(The)\\s+(.*?)(\\.[^.]+|)$","replace":"$2, $1$3"

(?# You can't use the ending parenthesis inside regex comments)
:: This is a commented line (:: is only special when they are the two first characters in a line)
(?# Disable default flags){flags:}Match once, casesensitive.

I'd appreciate comments, eventual improvements and so on.

Download:

  • ColEpisodes.js.txt (13.2 KB)
  • Download the file and drag it to the list under Preferences / Toolbars / Scripts.