Thread: [See Bugtracker] File Name Masks
View Single Post
Old 08.09.2018, 21:51
audio20's Avatar
audio20 audio20 is offline
Fibre Channel User
Join Date: Jun 2009
Posts: 125

Originally Posted by mgpai View Post
Hello, mgpai!

The last time I did program anything, it was probably more than 20 years ago and I was still using Pascal...

I took the sample script that you provided and tried to modify it for my own personal use; I started reading some JavaScript reference material around the web but soon realized it wasn't "reeeeeeeally" necessary for this kind of task (as long as I already had your code in hand).

I would like to thank you and leave another reference here just in case anyone else would like to adapt their own script tailored to their use.

// Script to Replace a few characters in the filename inside LinkGrabber
// Trigger: Packagizer Hook
// Strip a sequence of characters like: "&.#40;"
// Strip Parenthesis and Brackets: "(", ")", "[", "]"
// Strip Apostrophe and Comma: "'", ","
// Replace multiple spaces with a single one

var fn = link.getName();
var re = /(\&#.\d\d?;|[\(\)\[\]',])/g;

if (re.test(fn)) link.setName(fn.replace(re, "").replace(/\s+/g, " "));
Reply With Quote