using script and item path
Hi guys, I have a script below that I think should work, but I'm getting uncaught post script errors 'unterminated character class' and I don't know what's wrong.
Here's the script:
function (index, item) {
var regex = new RegExp("^.*\\([^\\]+)\\[^\\]+$", "gi");
var matches = regex.match(item.path);
return matches[1]+ '_' + item.filename;
}
basically the script tries to grab the parent folder name of the file and prefix the filename.
Help is very much appreciated, thank you :).
Here's the script:
function (index, item) {
var regex = new RegExp("^.*\\([^\\]+)\\[^\\]+$", "gi");
var matches = regex.match(item.path);
return matches[1]+ '_' + item.filename;
}
basically the script tries to grab the parent folder name of the file and prefix the filename.
Help is very much appreciated, thank you :).
Reply to #1:
I think it is the [^\\] part it doesn't like.
I think it is the [^\\] part it doesn't like.
Reply to #2:
Too hard to figure out so I gave up XD
Too hard to figure out so I gave up XD