Replace with regexp filename

This Action has doesn't work. How should I adjust to get it to set the filename to XXX?

Replace with regular expression

Field:
_FILENAME
Regular expression:
%_FILENAME%
Replace matches with:
XXX
[X] case-sensitive comparison

Thanks.

QUOTE (chrisjj @ Feb 1 2010, 16:49) <{POST_SNAPBACK}>
This Action has doesn't work. How should I adjust to get it to set the filename to XXX?
Replace with regular expression

Field:
_FILENAME
Regular expression:
%_FILENAME%
Replace matches with:
XXX
[X] case-sensitive comparison

Thanks.

Change
"Regular expression:
%_FILENAME%"

TO

(.*?)

It should work.
"Replace with regular expression" finds blocks of characters of the given criteria, (.*?) matches all characters possible in the given field - you cannot use the name of the field itself, although I see your logic.

QUOTE (chrisjj @ Feb 1 2010, 17:49) <{POST_SNAPBACK}>
This Action has doesn't work. How should I adjust to get it to set the filename to XXX?
Replace with regular expression

Field:
_FILENAME
Regular expression:
%_FILENAME%
Replace matches with:
XXX
[X] case-sensitive comparison

Thanks.


I think you have to enter .* instead of %_FILENAME% ...

But then again: as this is mainly a filesystem-function I would use either ...
... the function tag - filename and simply enter xxx but no tag-fields
.... or the dos-command-shell

ren *.mp3 XXX.mp3

That gives a filename of XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX approximately!

That fails too: it gives XXXXXX

Thanks but that is what I'm trying to improve upon - I want the rename included in an existing Action group.

LOL.

I was sure that the brackets+? forces the search in a text to get the full field..
Anyway I think you should use Format Value then.
Set the format string to XXX and the field to _FILENAME.
This is the most straightforward solution I believe.

have you tried the action "Format field" on the field _filename and entered XXX for format string?

That works thanks.

Still it would be nice to have the flexibility of regexp... if anyone can show how to get this simple case working.

Thanks for the solutions people, but can anyone explain why my first attempt does not work.

you cannot enter a field value variable in the find string. you have to use a regular expression like $if(%_filename% = %_filename%) which then becomes true to indicate that MP3tag should continue with the replace action.
(Note: Probably I miss a 1 or comma in my reg-exp)

Um, that's not a valid regular expression.

Whereas my %_FILENAME% is.

Looks like an Mp3tag format string to me.

It is that too. But are you implying it is not a valid regular expression???

It definitely is a valid regular expression -- only that it matches the string "%_FILENAME%" only (which doesn't help you much).

Just tried to focus on the problem at hand.

Ah, so Mp3tag does not treat it as a placeholder.

Home come? Given the Help says scripting functions (presumably including placeholders) are allowed in this Action type.

Yes, placeholders and scripting functions are not evaluated in the regular expression field.

Well, this suggests they are

https://docs.mp3tag.de/scripting
The scripting functions are available at these parts of Mp3tag:
Action, Replace with regular expressions

and I saw nothing to suggest they are not.

I think the Help and program should be made to accord.

Thanks Florian for the explanation.

The help topics are not too detailed anyway. could do with an update/rework, starting from sketch rewriting things so more things are clear and covered

Agreed, but detail is one thing. Accuracy is another... worth addressing now, I suggest! :slight_smile:

Well, true. The (relatively) small amount of info contains stuff like you jsut described. i THOUGHT %_FILENAME% would not work but was just intuition, had not learnt anywhere from the Help or anything.