Something strange is happening here. It appears as if the pattern match is resetting the capture groups before I can use them.
First, I tested the regex using Ruby, which has pretty much the same regex syntax as java, but a slightly different way of referring to back references (\ instead of $)
Code: Select all
1.9.3-p429 :024 > pat = /(([^.]*)([.].*))$/
=> /(([^.]*)([.].*))$/
1.9.3-p429 :025 > "Wuthering Heights 1939.m4v".gsub(pat, '\\2/\\1')
=> "Wuthering Heights 1939/Wuthering Heights 1939.m4v"
The first capture group gets the entire file name, while the second only gets the filename sans extension.
So I reworked the replacement string to java format:
Code: Select all
filebot.sh -script fn:sysenv --action test --def "e=(([\^.]*)[.].*)\$" "r=\$2/\$1"/volume1/video/movie
args[5] = e=(([\^.]*)[.].*)$
args[6] = r=$2/$1
But this still doesn't work.
Code: Select all
[TEST] Rename [/volume1/video/movie/Wuthering Heights 1939.m4v] to [/volume1/video/movie/Wuthering Heights 1939/.m4v]
So a change for debugging change the replacement to > 2: '$2' / 1: '$1' **
Code: Select all
filebot.sh -script fn:replace --action test --def "e=(([\^.]*)[.].*)\$" "r= > 2: '\$2' / 1: '\$1' **" /volume1/video/movie
[TEST] Rename [/volume1/video/movie/Wuthering Heights 1939.m4v] to [/volume1/video/movie/Wuthering Heights 1939> 2: '' / 1: '.m4v' **]
I'm certain that I'm quoting the replacement correctly, if I use \\\$2 instead of \$2 the replacement string has $2 instead of an empty string
It looks like the first capture is being reset before the replacement string gets to it. I still don't understand where the directory name is coming from:
Code: Select all
/volume1/video/movie/Wuthering Heights 1939.m4v to
/volume1/video/movie/Wuthering Heights 1939> 2: '' / 1: '.m4v' **
I see in the replace script where the pattern and replacement strings are used:
Code: Select all
renamePlan[f] = pattern.matcher(f.path).replaceAll(r) as File
But I don't understand what's happening inside FileBot itself.