[HELP] Missing information leaving blank spaces in filename.
[HELP] Missing information leaving blank spaces in filename.
As you can see on the screenshot above if the group is missing I'm left with a set of empty square brackets and if the source is missing there's an unnecessary space after the bracket. Some of the schemes I've seen seem to use an & symbol to prevent this somehow if a certain piece of info is missing but I don't know how to, please help.
Also, notice that "Magi - The Kingdom of Magic" has 2 folders because some of the episodes have a different video codec, is there anyway to write the code so that it'd be one folder containing the two codecs in this format: "AVC-x264" instead of splitting into two folders?
Thanks in advance for any help!
Re: [HELP] Missing information leaving blank spaces in filename.
That's all in your format, which you neglected to share here.
1.
Looking at your other thread, this format is gonna give you unnecessary spaces:
This expression will handle undefined bindings correctly:
2.
FileBot can't know in advance what files you're processing. If you rename x264 today and AVC tomorrow then FileBot couldn't possibly know about AVC at the time of renaming x264.
If you process all your files in a single batch then it's not impossible:
1.
Looking at your other thread, this format is gonna give you unnecessary spaces:
Code: Select all
({source} {vf} {vc} {ac})
Code: Select all
{allOf{source}{vf}{vc}{ac}.join(' ')}
2.
FileBot can't know in advance what files you're processing. If you rename x264 today and AVC tomorrow then FileBot couldn't possibly know about AVC at the time of renaming x264.
If you process all your files in a single batch then it's not impossible:
Code: Select all
{model.vc.unique().join('-')}
Please read the FAQ and How to Request Help.
Re: [HELP] Missing information leaving blank spaces in filename.
Thank you very much that's exactly what I wanted for both cases. Sorry I forgot to include my format I'll include that here in-case someone else has the same question:
Code: Select all
I:/Anime/{primaryTitle.replace(': ',' - ')} [{n.findMatch(group) ? null : group}] ({source} {vf} {vc} {ac})/{primaryTitle.replaceAll(/(?<=\w)[\w\s]/, '').replace(': ', '-')} {absolute.pad(2)} - {t.replace(': ', ' - ')}
Re: [HELP] Missing information leaving blank spaces in filename.
So I tried combining the two things you taught me and came up with this:rednoah wrote:That's all in your format, which you neglected to share here.
1.
Looking at your other thread, this format is gonna give you unnecessary spaces:This expression will handle undefined bindings correctly:Code: Select all
({source} {vf} {vc} {ac})
Code: Select all
{allOf{source}{vf}{vc}{ac}.join(' ')}
2.
FileBot can't know in advance what files you're processing. If you rename x264 today and AVC tomorrow then FileBot couldn't possibly know about AVC at the time of renaming x264.
If you process all your files in a single batch then it's not impossible:Code: Select all
{model.vc.unique().join('-')}
Code: Select all
I:/Anime/{primaryTitle.replace(': ',' - ')} [{n.findMatch(group) ? null : group}] ({allOf{model.source.unique().join('-')}{model.vf.unique().join('-')}{model.vc.unique().join('-')}{model.ac.unique().join('-')}.join(' ')})/{primaryTitle.replaceAll(/(?<=\w)[\w\s]/, '').replace(': ', '-')} {any{absolute}{'S'+special}.pad(2)} - {t.replace(': ', ' - ')}
Re: [HELP] Missing information leaving blank spaces in filename.
1.
You'll need to remove null from the List. Since the logic is the same for all the attributes you want you can further pull things together:
2.
This should do for the group part:
Assuming that all files have a group. If you get null values that's a hint for posting them: viewtopic.php?f=5&t=4
You'll need to remove null from the List. Since the logic is the same for all the attributes you want you can further pull things together:
Code: Select all
{model.collect{ [it.source, it.vc, it.ac] }*.minus(null)*.unique()*.join('-').join(' ')}
2.
This should do for the group part:
Code: Select all
{model.group.unique()}
Please read the FAQ and How to Request Help.
Re: [HELP] Missing information leaving blank spaces in filename.
It seems we might've had some miscommunication and there seems to be a little hitch in my current format:
And the output looks like this:
Something seems to be wrong in this part:
Code: Select all
I:/Anime/{primaryTitle.replace(': ',' - ')} {model.group.unique()} ({model.collect{ [it.source, it.vc, it.ac] }*.minus(null)*.unique()*.join('-').join(' ')})/{primaryTitle.replaceAll(/(?<=\w)[\w\s]/, '').replace(': ', '-')} {any{absolute}{'S'+special}.pad(2)} - {t.replace(': ', ' - ')}
Something seems to be wrong in this part:
And with this part, what I wanted is for the square brackets to be gone altogether if the group information is missing but I'm getting a null with brackets and adding ".minus(null)" still left the square brackets behind:rednoah wrote:1.
You'll need to remove null from the List. Since the logic is the same for all the attributes you want you can further pull things together:Code: Select all
{model.collect{ [it.source, it.vc, it.ac] }*.minus(null)*.unique()*.join('-').join(' ')}
For one thing I'm not even sure how the square brackets come-in for the group with the format written like this. Please help me out.rednoah wrote:2.
This should do for the group part:Assuming that all files have a group. If you get null values that's a hint for posting them: viewtopic.php?f=5&t=4Code: Select all
{model.group.unique()}
Re: [HELP] Missing information leaving blank spaces in filename.
1.
Try this:
2.
The result of {model.group.unique()} is a List and the [a, b, c] is part of the default String representation of a List.
@see http://docs.groovy-lang.org/latest/html ... tml#_lists
Try this:
Code: Select all
{model.source.minus(null).unique().join('-')}
The result of {model.group.unique()} is a List and the [a, b, c] is part of the default String representation of a List.
@see http://docs.groovy-lang.org/latest/html ... tml#_lists
Please read the FAQ and How to Request Help.
Re: [HELP] Missing information leaving blank spaces in filename.
Well it seems I'm right back where I started only with the multiple folder issue solved.rednoah wrote:1.
Try this:Code: Select all
{model.source.minus(null).unique().join('-')}
Current format:
Code: Select all
I:/Anime/{primaryTitle.replace(': ',' - ')} [{n.findMatch(group) ? null : group}] ({allOf{model.source.minus(null).unique().join('-')}{model.vf.minus(null).unique().join('-')}{model.vc.minus(null).unique().join('-')}{model.ac.minus(null).unique().join('-')}.join(' ')})/{primaryTitle.replaceAll(/(?<=\w)[\w\s]/, '').replace(': ', '-')} {any{absolute}{'S'+special}.pad(2)} - {t.replace(': ', ' - ')}
Thanks for all the help so far and please bear with me.
Re: [HELP] Missing information leaving blank spaces in filename.
1.
I'll think about adding some built-in helpers to make this use case easier.
In the meanwhile, this should do:
2.
Use this for your group expression:
@see viewtopic.php?f=5&t=1895
I'll think about adding some built-in helpers to make this use case easier.
In the meanwhile, this should do:
Code: Select all
{model.collect{ [it.source, it.vc, it.ac] }.transpose()*.minus(null)*.unique()*.join('-').join(' ')}
2.
Use this for your group expression:
Code: Select all
{"[$group]"}
Please read the FAQ and How to Request Help.
Re: [HELP] Missing information leaving blank spaces in filename.
Tuned into this thread a bit late, but I have some advice. For the group binding, another fix is to just move the brackets inside and it'll only use them if group is defined.
Another workaround for the whole AVC/x264 thing. Just replace the 'x264' part with whichever one you prefer.
Also, on your issue with the space because of source being undefined, I'm not quite sure what's going on. Why are you using "{model.source}" instead of just "{source}"? Maybe I just missed something, but it doesn't seem to help anything. If you use the regular source binding, that issue with the space won't happen.
Code: Select all
Old way: [{n.findMatch(group) ? null : group}]
New way: {[n.findMatch(group) ? null : group]}
Code: Select all
{vf =~ /AVC|x264/ ? 'x264' : vf}
Re: [HELP] Missing information leaving blank spaces in filename.
The OP wants x264 and AVC in the path if files with multiple video codecs are processed together. {model} gives you access to the rename context and all bindings for all matches in that context. So if you process a single file alone the format may come up with a different path compared to processing the same file alongside a bunch of other files.
Please read the FAQ and How to Request Help.
Re: [HELP] Missing information leaving blank spaces in filename.
I am also trying to get rid of [] when the fields are empty. I have to say, moving the [] inside of the { } was way too simple! Thanks for that!!!! Worked like a dream!Crankrune wrote: ↑21 Oct 2016, 20:47 Tuned into this thread a bit late, but I have some advice. For the group binding, another fix is to just move the brackets inside and it'll only use them if group is defined.
Code: Select all
Old way: [{n.findMatch(group) ? null : group}] New way: {[n.findMatch(group) ? null : group]}
Re: [HELP] Missing information leaving blank spaces in filename.
Do you wanna know why that works?
[0,1,2,3] is array syntax, so you return an Array / List object, and the default String representation kinda looks like the code. And if the code fails, no List object, and so no [...] in the output.
[0,1,2,3] is array syntax, so you return an Array / List object, and the default String representation kinda looks like the code. And if the code fails, no List object, and so no [...] in the output.
Please read the FAQ and How to Request Help.
Re: [HELP] Missing information leaving blank spaces in filename.
Yeah...that one actually made sense to me. Took me back to when I did programming in the 80's in c and assembler. I'm starting to remember some. I have always LOVED boolean logic. Friend of mine was a master at it and taught me a lot. Have not thought about it in about 30 years!!