Spaces removal

Hello

I would like to know what should I put in the _ALL tag format value, to get rid of errors which are defines as more than one space in a row

So in my system

" " [one space]

is correct, but

"  " [two spaces]
"   " [three spaces]

etc. is the incorrect state, no matter which TAG field

And so 2, 3, 4 etc. spaces should be found [I don't know how], and changed to one space [I know how]; but if a single space is at the very beginning or at the very end of any given value in any tag field, then even a single space like that is to be removed [I don't know how]

To replace more or less any number of white space characters with just one use an action of the type "Replace with regular expression"
Search string: \s+
Replace string:
(a single space)
To remove all white spaces at the beginning or the end of a field, use an action of the type "Format tag field" for that field:
Format string: $trim(%fieldname%)

Alternatively, actions of the type "Replace with regular expression" with the following search strings:
Front: ^\s
End: \s$
The replace string is left empty.

Remove leading and trailing space characters ...
Actiontype 4: Replace with regular expression
Field: _ALL
Regular expression: ^\x20+|\x20+$
Replace matches with:

[_] case-sensitive comparison

Replace multiple space characters with one space character ...
Actiontype 4: Replace with regular expression
Field: _ALL
Regular expression: \x20+
Replace matches with: \x20

[_] case-sensitive comparison

Note:
_ALL = _TAG + _FILENAME_EXT

The pseudo tag-field _ALL includes _FILENAME_EXT
... therefore trailing spaces on the filename ... for example ...
"filename .mp3"
... are not really trailing spaces but inner spaces.

Note:
Actiontype 5: Format value
Field: _FILENAME
Formatstring: $regexp(%_filename%,'\s+$',)
... or ...
Actiontype 4: Replace with regular expression
Field: _FILENAME
Regular expression: \s+(.[^.]+)$
Replace matches with: $1

[_] case-sensitive comparison

... removes all trailing white space characters from the filename, ...
from "filename .mp3" to "filename.mp3".

Note:
The pseudo tag-field _ALL includes UNSYNCEDLYRICS and COMMENT
... therefore multiple spaces sometimes may be allowed.

Note:

$len($regexp($char(9)$char(10)$char(11)$char(12)$char(13)$char(32)$char(133)$char(160),'\s',)) ==> 0

... therefore UNSYNCEDLYRICS and COMMENT are at risk, ...
when using the pseudo tag-field _ALL, ...
because these tag-fields often contain characters of the regexp class \s.

DD.20150302.2010.CET, DD.20150303.1206.CET

That works

That works also

But "format field" doesn't process "_ALL" in its "field" [like "Replace" / "Replace with regular expression"]. Which means I would have to make an separate entry [action in group] for every tag field that I use; and would have to rememember to add a new entry if I start to use a new one

That takes cares of the aforementioned new problem, because I can apply this to "_ALL"

But that makes a new new problem, because it changes one field to many: I would like the original additional spaces to remain in FILENAME. And that's because I use a whole set of actions to copy FILENAME to TITLE tag, make automatic changes to other tag fields - while retaining the TITLE tag almost unchanged for comparison with original FILENAME and making eventually manual changes to TITLE; and only after that coping it to FILENAME [so this step serves me as a kind of fail safe, because there can be additional tagging information and instructions in the original FILENAME; putted there by me after many spaces, so that there would be easily visible]

So is it possible to use some kind of expression like "_ALL but not FILENAME"? Or do I have to workaround by making "format fields" for all of my [tag] fields except FILENAME?

It is either all or specific fields. No exception.
It might be worth thinking of a concept where you write the filename last as a result from cleaned up tag fields.

So how do I get rid of a single space at the end of a FILENAME?

As as tested, I have no problem with changing the multiple spaces at the end into one, but that one then stays there; in TITLE tag the space is gone, but the

Regular expression "_ALL": "\s$" -> ""

doesn't seem to affect FILENAME in the same matter as tag fields

Yes, see the help for that:
http://help.mp3tag.de/options_format.html#regexp
"Note: At this action _FILENAME applies to the whole file name including its extension".
So you have to treat that separately, e.g. with "Replace with regular expression"
Search string: \s+.mp3
Replace string: .mp3

Now it works for FILENAME

Although a more inclusive / universal version would be

Regular expression
Field: _FILENAME
Regular expression: \s+\.*
Replace matches with: .*

[But it seems that I can replace matche with only "." and don't have to use "*" in addition]

QUOTE (zerow @ Mar 3 2015, 10:42) <{POST_SNAPBACK}>
Now it works for FILENAME

Although a more inclusive / universal version would be

Regular expression
Field: _FILENAME
Regular expression: \s+\.*
Replace matches with: .*

[But it seems that I can replace matche with only "." and don't have to use "*" in addition]


The search pattern you have given reads:
search for any number of white spaces followed by any number of dots ... whenever you get more than one dot in a row.
The replace stringj reads:
Replace anything you found with a dot. The asterisk shouldn't modify the result or the OS does not accept it as it is an illegal character for a filename. So you should leave that out.

The above expression would render
... and then there were three ... .mp3
(Genesis)
to
"....*and.*then.*there.*were.three..*mp3.mp3"
But as the operting system does not like the *
it becomes
....and.then.there.were.three..mp3.mp3

So it may be more universal, but the result is somewhat suprising.

And so I can't use it, because there could be a song title with "..." at the end

So now my next question would be: is there a sign / expression, that would order the retaining of the original extension?

If you operate on one kind of files it [MP3] it is not a problem. But when heaving two [MP3s, FLACs] or more it would require a seperate version for every extension. And what's more important, a caution in using them [choosing the right action group for the right extension]; and that's quite an opposite of automation

I doubt that. I think that changing manually the filename is the opposite of automation. Writing one more set of instructions can hardly be compared to that.
Use the field _filename_ext
Try as serach string: (.)\s+.(.)$
Replace string: $1.$2

Maybe it's me, but that is not working

But to get rid of a space like that
"Title Of Song... .mp3"
"Title Of Song... .FLAC"

I can use

Format value: _FILENAME
Format string: $trim(%_filename%)

How about if I would like to change TITLE tag
"... Name Of Song"
into
"...Name Of Song"

How can I limit replacement to only the beginning of a tag field, merging the first word ["..."] with second word [unspecified amount of any kind of characters]?

We are now discussing one exception after the other.
As a particular awkward turn it is to me when a solution for absolutely inexplicable reasons is not elegant enough.
It is an absolutely trivial task to replace a partial string of dot-blank with just a dot.
this would be the case of
"... Name Of Song"
as well as for
Title Of Song... .m

How can it be that the TITLE field has a blank at the end?
And if it does not have one, why don't you use the Convert>Tag-Filename function?

Now I use always the same naming system

But when adding a new files, they can have errors, mostly made by other people. And I know what errors that can be. And also there is the issue of all those old files, who are named correctly only in theory [when my naming system what a little different]

In past few days I created automation process, divided for a fail safe reasons into three steps, which will save me a lot of time in the future and correct many glitches without my knowledge. [I could push it even much further, but in time it would make some new kind of errors that could potentially turn into a lost of correct information and not just some typos]

The first case ["... " at the end of FILENAME] is for me an error of completely different background [source] than the second case ["... " at the beginning of TITLE]; and as such there are not dealt with at the same time [step]

And I don't know if i understood you correctly. But I know that for most people it wouldn't make a difference, if they had one or the other from below [made up by me] list of title versions:

  • "...And Justice For All... In Your Dreams!"
  • "... And Justice For All... In Your Dreams!"
  • "... And Justice For All ... In Your Dreams!"
  • "... And Justice For All ...In Your Dreams!"
  • "...And Justice For All ... In Your Dreams!"
    But for me ordnung is a vital thing
$if($eql($regexp(%TITLE%,'^(\.{3}) +(.+)$',),),
     <!--coloro:#800080--><span style="color:#800080"><!--/coloro-->$regexp<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->(<!--colorc--></span><!--/colorc--><!--coloro:#0000a0--><span style="color:#0000a0"><!--/coloro-->%TITLE%<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->^(\.{3}) +(.+)$<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->$1$2<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#0000a0--><span style="color:#0000a0"><!--/coloro-->%TITLE%<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->

... or ...

'...'$trimLeft(%TITLE%,'. ')

DD.20150303.2348.CET

Is this suppose to be a code for "Regular expression" and "Replace matches with"?

If yes, then something is not right; because I get an error info about unmatched marking parenthesis

This works

But there is a side effect to this: when there is no "..." somewhere in the beginning [as a first word], it simply adds "..." to the beginning of given field value

The script code text I wrote ... for better legibility and clarity ... into two lines, ...
this text you have to write into one line as the formatstring for an action "Format value".

Yes, that you have to consider before, ... for example ....

$ifgreater($len(%TITLE%),$len($trimLeft(%TITLE%,'. ')),'...'$trimLeft(%TITLE%,'. '),%TITLE%)

... and this is also an idea ...

From: To: ...ABC...DEF... ...ABC...DEF... ... ABC...DEF... ...ABC...DEF... ... ABC ...DEF... ...ABC...DEF... ... ABC ... DEF... ...ABC...DEF... ... ABC ... DEF ... ...ABC...DEF... ...ABC ... DEF ... ...ABC...DEF... ...ABC... DEF ... ...ABC...DEF... ...ABC...DEF ... ...ABC...DEF... ...ABC ...DEF... ...ABC...DEF... ...ABC... DEF... ...ABC...DEF... ....ABC....DEF.... ...ABC...DEF... $regexp(%TITLE%,'\s*\.{3,}\s*','...')

DD.20150304.2245.CET

And also: how about I would need to find a specific sing [for example "X"] at the beginning of the TITLE field; and it's variation "X " [X plus a pause]. How could I do that?

If I could pint point an "X", which could merged with a first word [like in "XTitle Of Song"] or have space on its right side [like in "XTitle Of Song"], then I could change it to my likening [probably into a single space, because I already know to get rid of unwanted spaces]

I think you already got the link to the help page on regular expressions
http://help.mp3tag.de/options_format.html#regexp
(see post #7)
The help will reveal to you how to address the beginning of a field.

I've failed in constructing a code from a scratch

But I've managed to use some info from that link to modify some previous ones; ans so there is no need for me to create yet another one