Quote:
Originally Posted by raztoki
personally I would use two rules, along the lines of [^A-Za-z0-9\.\-]+ and replace with " " as first can have multiple spaces generated, which then still don't match as direct filename mirrors
and second rule to remove multiple spaces for single \s+ replace with " "; raztoki
|
I did the code for a linkgrabber button that does the 2 replace but i'm strugling with the equivalent packagizer rule (it would be best done there).
Here is what I tried:
Filename contains ([^A-Za-z0-9\.\-]) then set Filename:<jd:orgfilename:1> works great but the replace multiple spaces by one space has got me confused. I think this means to weed out blocks of two spaces ([^(\s{2,})]) but I don't know how to tell it to replace by 1 space.
(rest not interesting for you raz)
My filename and packagename cleaner custom event (button in linkgrabber). It cleans out all linkgrabber links, selected or not - and there is no ctrl-z or preview so use with some care.
Code for button (for users reading this thread)
Code:
//Add your script here. Feel free to use the available api properties and methods
var regex1 = /[^A-Za-z0-9\.\-]/g;
var regex2 = /\s+/g;
//for all packages in linkGrabber
var packs = getAllCrawledPackages();
var newName = "";
for (var j = 0; j < packs.length; j++) {
var links = packs[j].getDownloadLinks();
for (var i = 0; i < links.length; i++) {
newName = links[i].getName().replace(regex1, " ");
newName = newName.replace(regex2, " ");
links[i].setName(newName);
}
packs[j].setName(/(.*)\./g.exec(newName));
}