JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 24.01.2017, 16:10
JerryL
Guest
 
Posts: n/a
Default How to customize substitution of invalid & other file/folder characters?

If a filename or folder has a semicolon, it gets replaced by an underscore "_". I want it to be replaced instead by a space and a hyphen " -". Is there any way to specify these and other custom substitutions for strings in file and folder names?
Reply With Quote
  #2  
Old 24.01.2017, 19:45
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

I'm sorry but that is not possible at the moment. At the moment the replacements are hardcoded. Any specific reason why you want this? You could create eventscripter that auto replaces _ with ' -'.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 24.01.2017, 19:57
JerryL
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
Any specific reason why you want this? You could create eventscripter that auto replaces _ with ' -'.
Oh yes, the reason is that I name all my music folders systematically with particular info and format. And that means, for me, separating components of folder name with a space delimited hyphen, sometimes also with tilda (for secondary titles in the name). I like to do this also for the downloaded archives, naming them to match the eventual folder name. All of this makes it easier to search for music, whether it is in folder or archive format. So it's very often an extra step to have to replace the underscore; many times it's the only change that's required.

However, I've never looked into the event scripter, so I will install that and try it out. That sounds it like it will be sufficient, as long as it can handle multi-character strings.
Reply With Quote
  #4  
Old 24.01.2017, 20:00
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

So you just want all _ replaced with ' -' or just ; ?
You can create auto rename rules with Settings-Packagizer.
Please provide some example links, then we can provide better help with packagizer rules.
The eventscripter is an extension where you can code scripts (in javascript) that react on events (eg new link added). In case you want to go with that solution, you can ask mgpai (in english) for help. He is very talented with it!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #5  
Old 24.01.2017, 20:24
JerryL
Guest
 
Posts: n/a
Default

Sorry, I just realized I wasn't being clear in my original description of the issue. The typical scenario is something like this:

I am editing a link caught by the LinkGrabber.
The file to download comes named like this:
Code:
XYZA.rar
I then usually copy my desired name from a web page and paste it over this to become:
Code:
X Y: Z A (2000).rar
but then, I have to change the ":" to " -". Instead of having it get subsituted by default with a "_".

This applies to both file names, renamed singly or multiply, and to package names.
So Packager rules will be applied after I first do the file or package renames above?

Last edited by Jiaz; 24.01.2017 at 20:26.
Reply With Quote
  #6  
Old 24.01.2017, 20:26
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

Packagizer rules are applied after linkcrawling only. So that solution won't work for you.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 24.01.2017, 20:28
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

You want all _ with ' -' or only the first one?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #8  
Old 24.01.2017, 20:43
JerryL
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
Packagizer rules are applied after linkcrawling only. So that solution won't work for you.
But the event scripter approach would work for this scenario?

Quote:
You want all _ with ' -' or only the first one?
Typically, there would just be that first one that replaced the ":" Other underscores that might appear later in the name can be left as-is since it would probably be for some secondary piece of info. For example, "24_96" could stand. Though, eventually, I would replace that with "24bit 96khz" in the final extracted folder name, and would consider doing that substitution as well in the event scripter if I was already doing the first change.
Reply With Quote
  #9  
Old 25.01.2017, 09:10
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

Yes, the eventscripter should be able to do that.
Another solution would be to rename all files manually and then select all and use the rename feature in JDownloader to rename all selected and there you can use regex/replace. That way you could do something like this
Search for (.*?)_(.+)
Replace with $1 -$2
That should replace the first _ to ' -'

With eventscripter you could write a script that automates this rename. Eg first rename all files, then click button to start script to auto rename/fix all names.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #10  
Old 25.01.2017, 14:09
JerryL
Guest
 
Posts: n/a
Default

I like the automatic eventscripter approach and can probably use that for other subtitutions as well. I did a lot of javascript in the past. Is there a reference page or doc available with the JDownloader javascript API?
Reply With Quote
  #11  
Old 25.01.2017, 15:10
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

Install the Eventscripter Extension. Then you can create new event and the editor will show all availble objects/methods above the input field. Feel free to ask us (support@jdownloader.org) or contact mgpai for help. He wrote nearly all scripts that you can find here in our board.
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 22:35.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.