IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Actions, Replacing, Case conversion, Regular Expressions, Macros
dano
post Apr 16 2004, 10:46
Post #1


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



1. How do I create a new action?

2. How do I change upper/lower case of tag-fields or filenames?

3. How do I replace the string "xyz" in tag-fields or filenames?

4. How do I append the string " xyz" to the content of a tag-field?


Examples:

Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 11:22
Post #2


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



How do I create a new action?

At first you have to create a new action group via Actions > mt_format.png Actions or [Alt+6].
Click on the button mt_new.png New and give your action group an expressive name, e.g., "All Tag-fields Upper Case".
This action group can be applied to the selected files after you have added one or more actions to it.

You can now create a new action in your action group via the button mt_new.png New and choose the desired action type from the list.

At the moment the following action types are availableYou can combine different actions (e.g., Case conversion and Replace) in one action group and activate or deactivate them via the checkmarks in the Actions > mt_format.png Actions dialog.

This post has been edited by dano: Jul 16 2012, 12:50
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 11:40
Post #3


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



How do I change upper/lower case of tag-fields or filenames?

Create a new action in an existing action group and choose Case conversion as action type.

On field you can choose which parts of the tags/filename should be changed.
Case conversion determines how the upper/lower case of the field will be changed.

If you want for example mark chars after a left parenthesis or a hyphen as the begin of a word, enter the respective char under Words begin from/after any of.


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 12:09
Post #4


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



How do I replace the string "xyz" in tag-fields or filenames?

Create a new action in an existing action group and choose Replace as action type.

On field you can choose to which parts of the tags/filename the replace rule should be applied.
On Original you enter the string that is due to be changed in field.
On Replace with you enter the text that replaces the string in Original. If you leave it empty, the string will be deleted.


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 12:20
Post #5


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



How do I append the string " xyz" to the content of a tag-field?

Create a new action in an existing action group and choose Format value as action type.

In Field you can choose to which tag field the formatting rule should be applied.
In Format string enter the placeholder for the field selected above and the string which should be appended.

Example:
If you want to append the string " xyz" to the current value of the comment field:

Action type: Format value
Field: COMMENT
Format string: %comment% xyz

You can use this also to add "xyz " in front of the tag value or to copy one value to another field.


This post has been edited by dano: Feb 27 2010, 13:43


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 13:50
Post #6


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Removing of strings

In order to remove strings, create a new action in an existing action group and choose Replace as action type.

Field: Here you can enter which field(s) you want to change. You can choose _ALL, which affects tags AND filenames, _TAG which affects all tag fields, _FILENAME which only affects the filename or one of the other supported tag-fields.
Original: Here you enter the string that you want to delete.
Replace with: Leave it empty because you want to delete the string in Original.

Example:
The filename ThisShouldRemainREMOVETHIS should be replaced by ThisShouldRemain. Just enter REMOVETHIS in Original.

Note:
The replacement rules are first applied to the filename and afterwards to the file extension since version 2.13. This means that the period as separator between filename and file extensions must NOT be entered. In order to rename void.mp3 in v.mp3 you must not enter "oid." in Original.


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 14:28
Post #7


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Pasting of strings

Question:
I want to paste spaces in the filename "Artist - Title" for better clearness and it should be like this: "Artist   -   Title". How does it work?

Answer:
Create a new action in an existing action group and choose Replace as action type.
In the now opening dialog enter:
In Field: "_FILENAME"
In Original: " - "
In Replace with: "  -  "

You can activate the action group via Convert, mt_format.png Actions and apply it to the selected files.

But unwanted duplication of the spaces can occur if you want to execute this action several times. "x - x becomes x  -  x", and "x  -  x becomes x   -   x" etc. You can prevent this by adding a second action that makes "   " (3 spaces) to "  " (2 spaces).

It is even more simple if your files are already properly tagged: you can use the converter mt_ttf.png Tag - Filename with the format string "%artist%  -  %title%" and get the same result.

This post has been edited by dano: Apr 6 2006, 07:43


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 16:32
Post #8


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Removing of a certain number of leading chars

Question:
I have some leading chars in the filename/tag. How can I remove them?

Answer:
Create a new action in an existing action group and choose Replace with regular expression as action type.
In Field, choose where you want to remove the chars.
In Regular expression enter ^.{3} if you want to remove 3 chars.
Replace matches with stays empty.
So you can enter the number of chars to be removed between the two curly brackets.

To remove the last 3 characters use .{3}$ (Do not use this on _FILENAME)

This post has been edited by dano: Jan 17 2010, 11:32


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 17:05
Post #9


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Removing of certain leading chars

Question:
Some titles start with "The", others with "Der" or "Die". But i can't just delete the 3 first chars because all other tags/filenames will be shortened, too. How can i remove only these chars?

Answer:
Create a new action in an existing action group and choose Replace with regular expression as action type.
In Field, choose where you want to remove the chars.
In Regular expression enter ^The\s+
Replace matches with stays empty.

If you execute this action on your selected files, all The's and successional spaces will be deleted. Of course it works the same way with other words.


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 18:53
Post #10


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Remove/trim leading/trailing spaces

Video tutorial for these actions:
http://www.vimeo.com/7756545

Leading spaces:
Action type: Replace with regular expressions
Field: _TAG
Regular expression: ^\s+
Replace matches with:

"^" matches the beginning of the string. Then "\s+" searches for all whitespaces till a different char occurs.
The whitespaces found will be replaced by nothing, therefore deleted.


Trailing spaces:
Action type: Replace with regular expressions
Field: _TAG
Regular expression: \s+$
Replace matches with:

This regular expression matches one and more (marked by +) spaces (marked by the \s specifier) at the end (marked by $) of a string.

To remove trailing spaces in the filename, one must take care of the extension, too.
Example:
Action type: Replace with regular expressions
Field: _FILENAME
Regular expression: \s+\.([a-z0-9]{2,4})$
Replace matches with: \.$1

NEW: Since Mp3tag v2.36 you can also use this action to remove leading and trailing spaces from the filename:
Action type: Format value
Field: _FILENAME
Formatstring: $trim(%_filename%)


Cut two or more consecutive spaces to one:
Action type: Replace with regular expressions
Field: _ALL
Regular expression: \s{2,}
Replace matches with: " "

This post has been edited by dano: Dec 8 2009, 13:50


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 18:54
Post #11


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Remove/trim leading track numbers

Action type: Replace with regular expressions
Regular expression: ^\s*\d+\s*-\s*
Replace matches with:

This regular expression removes the track number from "01 - Anything.." so that only "Anything..." remains.
"^" matches the beginning of the string. Then any numbers of whitespaces "\s*" followed by numbers from 0-9.
The \s*-\s* part removes the hyphen and any whitespace characters around it.

This post has been edited by dano: Nov 18 2007, 12:50


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 19:14
Post #12


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Separating strings that are written in one word

Question:
I have titles that have no spaces between words (written in one big word). However, all words start with a capital letter, e.g., ThisIsTheTitle. Can Mp3tag separate the individual words and insert a space before every capital letter?

Answer:
Create a new action group, e.g., TagsLikeThese for the field you wish to edit (the example uses the TITLE field):

Action type: Replace with regular expression
Field: TITLE
Regular expression: (\l)(\u)
Replace matches with: $1 $2
[x] case-sensitive comparison

or
Regular expression: (\w|,)(?=\u)
Replace matches with: $1 $2
[x] case-sensitive comparison

This post has been edited by dano: Feb 1 2010, 18:23


--------------------
Go to the top of the page
 
+Quote Post
dano
post Apr 16 2004, 19:24
Post #13


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



Upper case after an O' like O'Hugo

Question:
There are irish/scottish names like O'Donnel, O'Leary etc, that all should be upper case. But you cannot use upper case in general after an ' because the following examples are wrong spelled then (That'S, Ain'T etc.). How can I only get upper case after an O'?

Answer:
Create a new action in an existing action group and choose Replace with regular expression as action type.
Regular expression: O'(.{1})
Replace matches with: O'$upper($1)
[x] case-sensitive comparison


This post has been edited by dano: Nov 25 2011, 22:53


--------------------
Go to the top of the page
 
+Quote Post
dano
post Sep 11 2005, 13:13
Post #14


Moderator


Group: Moderators
Posts: 5683
Joined: 4-September 03
From: Germany
Member No.: 201
Mp3tag Version: 2.63



How can I swap the contents of 2 tag fields?

Example how to swap TITLE and ARTIST:

Create a new action in an existing action group or make a new action group.

Action type: Guess values
Source format: %title%~%artist%
Guessing pattern: %artist%~%title%

Note: The ~ sign is just used to make a separation between the two fields, you could take any other sign that does not appear in your fields, e.g. ¢ or an extended unicode character like ∞ or ∑ (v2.33 or higher required)

keywords: swap swapping


--------------------
Go to the top of the page
 
+Quote Post
Florian
post Feb 10 2010, 14:19
Post #15


Developer


Group: Admin
Posts: 7710
Joined: 12-December 01
From: Germany, Dresden
Member No.: 203
Mp3tag Version: 2.63



How can I copy one field value to another field?

Example how to copy the content of the ARTIST field to the ALBUMARTIST field:

Create a new action in an existing action group or make a new action group.

Action type: Format value
Field: ALBUMARTIST
Format string: %artist%

Note: If you want to copy all possible values of a field (in case you have multiple artist fields), the internal scripting function $meta_sep can be used in the format string, e.g., $meta_sep(artist,\\)

This post has been edited by dano: Dec 5 2010, 10:42


--------------------
♫ If you like using Mp3tag please donate to support further development.

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 2nd September 2014 - 22:17