RegExp Find & Replace 4.3 w/ 253 presets (2011-07-06) [MM2+]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Alterx
Posts: 21
Joined: Fri Jul 03, 2009 2:12 pm

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by Alterx » Mon Aug 03, 2009 6:02 pm

ZvezdanD wrote:
Alterx wrote:i'd like to Replace one custom field (let's say "Alternative Sort" field) with current value from "Artist" field and i want to swap "Surname, Name" to "Name Surname" (removing ",") but only if there is a "," in the source field
You want to modify two fields in same time using one preset which is not currently possible. However, you could get what you want using two existing presets:
1. Copy the Date when the file is last modified to the Date added field - just change fields with Into and From dropdown lists;
2. Swap the last and the first name of the Artist with removed ", ".
Not exaclty... maybe it's my poor english :)

I want to modify just one field: Custom 5 (Alternative Sort)

Of course i'd like to proceed with a two-step modification: first i replace the Custom Field and then i swap the value in "name surname".

By the way, i can understand the problem is that i will not be able to do this just with one script.... i'll use two script :)

Maybe this could be a sort of suggestion for further release of the script: the ability to run 1 preset with some other presets as argument (in my example: preset "Change Custom 5 Field" that can run the other two presets one after the other).

Thank you very much for your answer anyway.

Bye

Andrea

ZvezdanD
Posts: 3094
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by ZvezdanD » Mon Aug 03, 2009 6:58 pm

Alterx wrote:I want to modify just one field: Custom 5 (Alternative Sort)
I did understand that you want to modify Artist field as well. Well, if you want to modify only Custom field using data from Artist field then it is similar to the "Copy the Artist name to the Custom 3 field with moved prefixes to the end" preset - here is the modified Replace with string:

Code: Select all

RegSub(oSongData.ArtistName, "(.+?),(\s+)(.+?)($|\s&\s|;\s*)", "$3$2$1$4")
As you could see, the second argument of the RegSub function is same as the Find what string from the mentioned "Swap the last and the first name" preset and the third argument is same as the Replace with string from the same preset.

By the way, the suggestions for arguments and multiple presets was several times before and they are in development.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegSub Help

Post by CarlitoGil » Thu Aug 06, 2009 7:00 pm

ZvezdanD wrote:
GIL wrote:Do you ever wish you could get the version 35.9 of this script from the year 2025?
I am not sure that (I) understand. Do you want to say that there are too many updates of this script or that its development is too slow?
Too many, too slow? Compared to what?
Is just a thought,
now I say: how can I live or do many things without MM and this script
In the year 2025 with maybe version 35.9 we'll say: how could we have lived with version 3.6? Not that is bad.
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by CarlitoGil » Thu Aug 06, 2009 7:45 pm

Is there any way use variables?

I mean not captured from 'Find What' but to use a part of a VBScript expression

like
Set(Var,Value)
would be nice
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by CarlitoGil » Thu Aug 06, 2009 7:58 pm

Could you make the fields from SongDataDict load from an external file so that any custom order is not lost when updating?
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by CarlitoGil » Thu Aug 06, 2009 9:31 pm

Couldn't wait for the variables, so I added this

Code: Select all

Dim Variables(9)

Function SetVariable(Number,Value)
Variables(Number) = Value
End Function
Could it be added to the official script?
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

ZvezdanD
Posts: 3094
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by ZvezdanD » Fri Aug 07, 2009 9:00 am

GIL wrote:Couldn't wait for the variables, so I added this

Code: Select all

Dim Variables(9)

Function SetVariable(Number,Value)
Variables(Number) = Value
End Function
Could it be added to the official script?
This is very nice suggestion. However, I have another approach which allows to have dynamically adjusted size of array and also allows alphabetical variable names, not only numerical, i.e. you could write something like SetVar("My_variable", "some_value") and GetVar("My_variable"):

Code: Select all

Dim iVariable()
ReDim iVariable(0)
Dim oVariable
Set oVariable = CreateObject("Scripting.Dictionary")

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function SetVar(vVarName, vValue)
    If VarType(vVarName) = vbInteger Then
        If UBound(iVariable) < vVarName Then
            ReDim Preserve iVariable(vVarName)
        End If
        iVariable(vVarName) = vValue
    ElseIf oVariable.Exists(vVarName) Then
        oVariable.Item(vVarName) = vValue
    Else
        oVariable.Add vVarName, vValue
    End If
End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetVar(vVarName)
    If VarType(vVarName) = vbInteger Then
        If UBound(iVariable) >= vVarName Then
            GetVar = iVariable(vVarName)
        Else
            GetVar = ""
        End If
    ElseIf oVariable.Exists(vVarName) Then
        GetVar = oVariable.Item(vVarName)
    Else
        GetVar = ""
    End If
End Function
By the way, using this code, SetVar("1", "some_value") and SetVar(1, "some_another_value") gives two different values! This is because the first function has alphabetical variable name and the second one has numerical name.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by CarlitoGil » Fri Aug 07, 2009 10:11 am

you could write something like SetVar("My_variable", "some_value") and GetVar("My_variable")
Will this be in the official script?
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

ZvezdanD
Posts: 3094
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by ZvezdanD » Sat Aug 08, 2009 3:12 am

GIL wrote:Will this be in the official script?
Yes, it will be included. However, I need to think about a proper way for clearing those variables and releasing memory. I think that the best place for this is on the end of the Replace All command function and when closing of Find & Replace dialog box.

Did I say this is a very good suggestion? :) I think it could speed up some presets, especially those which have several SQLQuery functions. Thanks so much for this!
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by CarlitoGil » Wed Aug 12, 2009 11:42 pm

"Find what" and "Replace with" fields should use a fixed width font
I like 'Lucida Console', like in notepad

Is there a way for me to do this in the mean time?
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

ZvezdanD
Posts: 3094
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by ZvezdanD » Thu Aug 13, 2009 8:19 am

GIL wrote:"Find what" and "Replace with" fields should use a fixed width font
Yeah, I prefer monospaced fonts for such things like code editing. Unfortunately, combo boxes (dropdown lists with edit field) cannot have changed font. I could replace those combo boxes with simple text boxes, but in such case we could not have a typing history like now.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by CarlitoGil » Thu Aug 13, 2009 7:48 pm

You may have noticed there's a bug when working with functions that set variables
when using the function

Code: Select all

IIf(expr, truepart, falsepart)
Both truepart and falsepart seem to always be evaluated and call the funtcions in falsepart, like SetVariable, thus setting that variable when it should'nt
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

ZvezdanD
Posts: 3094
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by ZvezdanD » Fri Aug 14, 2009 12:13 am

GIL wrote:You may have noticed there's a bug when working with functions that set variables
when using the function

Code: Select all

IIf(expr, truepart, falsepart)
Both truepart and falsepart seem to always be evaluated and call the funtcions in falsepart, like SetVariable, thus setting that variable when it should'nt
It is not a bug. Visual Basic Language Reference - IIf Function (http://msdn.microsoft.com/en-us/library ... 71%29.aspx):
The expressions in the argument list can include function calls. As part of preparing the argument list for the call to IIf, the Visual Basic compiler calls every function in every expression. This means that you cannot rely on a particular function not being called if the other argument is selected by Expression.
http://en.wikipedia.org/wiki/IIf:
Another issue with IIf arises because it is a library function: unlike the C-derived conditional operator, both truepart and the falsepart will be evaluated regardless of which one is actually returned.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

CarlitoGil
Posts: 294
Joined: Sun Sep 07, 2008 10:46 am
Location: Dominican Republic
Contact:

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by CarlitoGil » Fri Aug 14, 2009 11:46 am

Thanks for the clarification
Obviously, I'm not too familiar with Visual Basic.
I forgot IIf is a custom fuction. Now it makes perfect sense

If you're adding a SetVariables to the script perhaps you should add this

Code: Select all

Function IIfx(expr, truepart, falsepart)
    If expr Then
        IIfx = Eval(truepart)
    Else
        IIfx = Eval(falsepart)
    End If
End Function
iTunesMonkey + Acoustid – Find metadata from iTunes and Acoustid

ZvezdanD
Posts: 3094
Joined: Thu Jun 08, 2006 7:40 pm

Re: RegExp Find & Replace 3.6 w/ 101 presets (2009-07-02)[MM2+3]

Post by ZvezdanD » Fri Aug 14, 2009 12:37 pm

GIL wrote:If you're adding a SetVariables to the script perhaps you should add this

Code: Select all

Function IIfx(expr, truepart, falsepart)
    If expr Then
        IIfx = Eval(truepart)
    Else
        IIfx = Eval(falsepart)
    End If
End Function
Nice try, but it is nothing different than existing IIf function. As you could see from M$ description, all arguments (expr, truepart, falsepart) are already evaluated before the function call. So, if you specify some function as argument, VBScript interpreter would evaluate that function first and its result will transfer to the IIf function.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

Post Reply