#1
|
|||
|
|||
![]()
I've come across a number of sites that now include #hashtag text in the filenames. I don't want those, as they tend to make the pathname excessively long.
I raised the question on this thread. I wrote this script to strip them out. It's called via Event Scripter using a Packagizer Hook: Code:
if (linkcheckDone) { var myPackagizerLink = link; var fileName = myPackagizerLink.getName(); var re, ext, newName; if (fileName !== null && fileName.includes("#")) { ext = fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2); if (ext !== "") { ext = "." + ext.toLowerCase(); } fileName = fileName.substr(0, (fileName.length - ext.length)); rgx = new RegExp("#[a-zA-Z0-9_]+", "gi"); newName = fileName.replace(rgx, ""); rgx = new RegExp("\\s\\s+", "gi"); newName = newName.replace(rgx, " "); newName = newName.trim(); myPackagizerLink.setName(newName + ext); } } |
#2
|
|||
|
|||
![]()
And from additional comments, I learn it's possible to do this same thing by going into Advanced Settings and adding the Regex to the Filename Replace Map.
I have mine set to: Code:
{ ":" : "", "\\|" : "¦", "<" : "[", ">" : "]", "/" : "\u2044", "\\\\" : "∖", "\\*" : "#", "\\?" : "¿", "\"" : "'", "‘" : "'", "’" : "'", "‘" : "'", "\u2013" : "-", "\u2018" : "'", "#[a-zA-Z0-9_]+" : "" } Gotta love JD... there's always more than one way to 'skin the cat', eh? |
#3
|
||||
|
||||
![]() Quote:
You can also add buttons to scripts which then modify values of advanced settings so there you have another way ![]()
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#4
|
||||
|
||||
![]()
+that you have move flexibility and can do way more, eg parsing name and search for information and rewrite stuff or check additional information, eg parse size/width/codec....from properties and add them to name
__________________
JD-Dev & Server-Admin |
![]() |
Thread Tools | |
Display Modes | |
|
|