RTTSoftware Support Forum
PDF-ShellTools => Ideas/Suggestions => Topic started by: Nick Riviera on January 17, 2023, 08:43:20 AM
-
Hello,
...can I replace a string from a filename with a custom script...?
something like this:
[ReplaceS:replace this|[myScript]]([f])
-
Not possible while using the builtin ReplaceS function (the parameters are fixed, not parsed for dynamic content), but doable with a custom script.
With a custom script, named ReplaceStr, with this code:
function ReplaceStr() {
var params = CurrentField.value.split(',', 3);
if (params.length == 3) {
return params[0].replace(params[1], params[2]);
}
}
you can then use this syntax: [ReplaceStr](source,searchValue,newValue)
With your example: [ReplaceStr]([F],replace this,[myScript])
-
thank you for reply and for the explanations
but,
I do not know if the function ReplaceStr does not work or I did not proceed correctly...
01_replace this_document.pdf
the result should be:
01_210x297mm_document.pdf
-
In your screenshot the [ReplaceStr] part of the expression is not showing in blue, so your custom scripts don't have a script named ReplaceStr. Probably you forgot to rename the newly added script or mistyped the name.
-
you're right,my mistake.. it's works..solved!Thanks!