by Luuk » Sat Jul 30, 2022 9:15 pm
Many apologies, I did first believe that all of your filenames should still be starting like... yt5s.com ??
But now Im guessing that some first-renames did already remove the yt5s.com, so must now remember....
The following if (conditions) will only test for how the names should end, so this some different ways that mightcan help...
To remove both conditions of yt5s.com at the beginning, and remove (AnyTextThatsNotParenthesis) from the ends of any filename...
if (/RegxFileMatch/.test(name)) {newName = name.replace(/--AnyRegex1--|---AnyRegex2---/g, '')}
if (/^.+\([^()]*?\)$/.test(name)) {newName = name.replace(/^yt5s.com[- ]+| *\([^()]*?\)$/g, '')}
To remove both conditions of yt5s.com at the beginning, and only remove (EndingText) that starts with a digit...
if (/Regex-File-Match/.test(name)) {newName = name.replace(/--AnyRegex1--|----AnyRegex2-----/g, '')}
if (/^.+\(\d+[^()]*?\)$/.test(name)) {newName = name.replace(/^yt5s.com[- ]+| *\(\d+[^()]*?\)$/g, '')}
To remove both conditions of yt5s.com at the beginning, and only remove ending-text like (360p) or (128 kbps) or (128 kps) or (1,280 bps)...
if (/Regex-File-Match/.test(name)) {newName = name.replace(/--AnyRegex1--|----- Any Regex2 -----/g, '')}
if (/^.+\(\d+[^()]*?\)$/.test(name)) {newName = name.replace(/^yt5s.com[- ]+| *\([\d,]+ *k?b?ps?\)$/g, '')}
But really, you dont need these if's anymore, since conducting files that dont need to begin with yt5s.com?
So instead of using... if (any-condition) {newName = whatever}, you can just use the newName = whatever parts.
Just be careful with the files being selected, or maybe to think of better conditions, to limit which files get renamed?
Im only used if (condition) {rename} in the first post, because it seemed like, not only must all of the files begin with yt5s.com,
But also, that the only files that should have their ending (text) removed, would be the filenames that also begin with yt5s.com.
So now, that very last code should really just look like...
newName = name.replace(/--AnyRegex1---|------AnyRegex2-------/g, '')
newName = name.replace(/^yt5s.com[- ]+| *\([\d,]+ *k?b?ps?\)$/g, '')
You could put a condition in front, like testing to see if its a video, but this does also make the conducting much slower...
if (/^video$/i.test(fileProperty('System.PerceivedType'))) {newName = name.replace(/^yt5s.com[- ]+| *\([\d,]+ *k?b?ps?\)$/g, '')}
If needing a condition in front, I would probably just test file-extensions, because its much faster than testing System.PerceivedType...
if (/wmv|mp4|mkv|mpe?g/i.test(ext)) {newName = name.replace(/^yt5s.com[- ]+| *\([\d,]+ *k?b?ps?\)$/g, '')}
I did see that before refreshing, there was a file without yt5s.com, but still having (128 kbps), so maybe some of these can help.
If its me, Im probably preferring the very last one, but please just to be careful with selecting which files to get renamed!