Page 40 of 109

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Sat Sep 25, 2010 7:42 am
by ZvezdanD
Guest wrote:Hello ZvezdanD, do you have a news letter about updates?
I looking forward to the batch function
You would be all informed here, in this thread, as well as on my download page when I release the new version (as I did so far). You could also use the Find updates button in the Tools/Extensions dialog box from time to time.

Folks, please consider a possibility to donate some money to me if you want to see the new version in the near future. You know, I already spent so much of my free time to write this add-on, however the mentioned function is not so easy to add and would require another large portion of my time to spend. Your donations would be really appreciated.

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Sat Sep 25, 2010 9:58 am
by Flytrap
ZvezdanD wrote:
Flytrap wrote:I am having difficulty with the preset called "Swap first and last name of <Into Field> with added ", "...". In the example it says, "John Lee Hooker -> Hooker, John Lee (works with multi-item fields as well)," but my results look like "Lee Hooker, John."
Thanks for the report, the fix will be included with the next version of this add-on. Here is the updated Find what string:

Code: Select all

(.+?)(\s+)([^\s]+?)($|\s&\s|;\s*)
Works like a charm! Thanks for the quick reply and the help!

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Sat Sep 25, 2010 7:37 pm
by beg
Hi,

sorry - overlooked that.. But then I have to remove the "-" from the end of the artist field since this is being copied there.

and I have problems finding the suggested
""Remove the begin of <Into Field> before (and including) "-" or " - "..." preset"

This is ment to be one of the 101 presets?

thx for you help!

Bernhard

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Sun Sep 26, 2010 3:39 pm
by ZvezdanD
beg wrote:I have to remove the "-" from the end of the artist field since this is being copied there.
Sorry, you could try with the next Replace with string:

Code: Select all

IIf(InStr(oSongData.Title, "-") > 0 And Len("$_") > 0, " con " & RTrim(Left(oSongData.Title, Max(InStr(oSongData.Title, "-") - 1, 0))), "$&")
beg wrote:and I have problems finding the suggested
""Remove the begin of <Into Field> before (and including) "-" or " - "..." preset"

This is ment to be one of the 101 presets?
The latest version of this add-on has 207 predefined presets, so I suppose that you have installed some old version.

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Mon Sep 27, 2010 2:10 pm
by beg
ZvezdanD wrote:
beg wrote:I have to remove the "-" from the end of the artist field since this is being copied there.
Sorry, you could try with the next Replace with string:

Code: Select all

IIf(InStr(oSongData.Title, "-") > 0 And Len("$_") > 0, " con " & RTrim(Left(oSongData.Title, Max(InStr(oSongData.Title, "-") - 1, 0))), "$&")
beg wrote:and I have problems finding the suggested
""Remove the begin of <Into Field> before (and including) "-" or " - "..." preset"

This is ment to be one of the 101 presets?
The latest version of this add-on has 207 predefined presets, so I suppose that you have installed some old version.
Yes I had an old version. Installed the new one. Thanks!

Your replacement string worked well, thx!
But the preset
Remove the begin of <Into Field> before (and including) " - "...
which should do:
The Beatles - Let It Be -> Let It Be
in my title field is not working. I selected title, but it does no replacing/deleting of the part before the "-"
Maybe because I have no space in front of the "-" in my titles?

"part1-part2" instead of "part1 - part2" like in the example?

cheers,
Bernhard

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Mon Sep 27, 2010 3:41 pm
by ZvezdanD
beg wrote:But the preset
Remove the begin of <Into Field> before (and including) " - "...
which should do:
The Beatles - Let It Be -> Let It Be
in my title field is not working.
I suggested the "Remove the begin of <Into Field> before (and including) "-" or " - "..." preset which is the next preset in the list immediately after the one that you tried. You could even use the "Remove the begin of <Into Field> before (and including) specified string..." preset with specified the "-" in the Trim string before text box.

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Mon Sep 27, 2010 7:08 pm
by beg
Hi ZvezdanD,

sorry - my mistake! I am not really into that addon.. :(
worked perfectly!

thank you so much for your help!
cheers,
Bernhard

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Fri Oct 15, 2010 8:03 am
by Milagro
Can someone give me a tip on the "Remove specified string from the begin of <Into Field>..." function.
I have recently update my file name but I resulted in the lost of my meta-data so I want to rename the files to there original name.

The current structure of the file name is "Song Key - BPM - ID. SongName.mp3"

Example:
10A - 100 - 2980. SongName.mp3
2B - 88,99 - 018. SongName.mp3

I like to rename them to "ID. SongName.mp3"
2980. SongName.mp3
018. SongName.mp3

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Fri Oct 15, 2010 10:18 am
by ZvezdanD
Milagro wrote:The current structure of the file name is "Song Key - BPM - ID. SongName.mp3"

I like to rename them to "ID. SongName.mp3"
Find what:

Code: Select all

^[^-]+? - \d+?(?:,\d+)? -\s
Into: Filename
Regular expression 1: checked
Replace with: empty

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Sat Oct 16, 2010 4:44 am
by Milagro
Thanks that is excellently what I needed.
How can I transform this for my song title "Song Key - Song Title" to "Song Title"

I tried this "Replace specified string with another one in <Into Field>..." with ^[^-]+? \s

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Sat Oct 16, 2010 8:32 am
by ZvezdanD
Milagro wrote:How can I transform this for my song title "Song Key - Song Title" to "Song Title"
You could use the preset "Remove the begin of <Into Field> before (and including) " - "...".

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Tue Oct 26, 2010 7:28 am
by FunnyFish
I am a heavy (and very content) Regexp user, but I'm having problems with the new SETVAR function.

I'm using setvar() in this script, which should check if the file name length exceeds the 64-char maximum for CD's and puts a message in the Lyricist field (that I don't use):

Find what:
^.*$ (Lyricist, RegExp 1)

Replace with:

iif (setvar (totlen, setvar (trlen, len (osongdata.trackorderstr) ) + iif (getvar (trlen) > 0, len (" - ") , 0 ) + len( osongdata.artistname ) + len (" - ") + Len( osongdata.title )) > setvar (maxplen, 64), "Warning:file name exceeds " & getvar (maxplen) & " characters(" & getvar (totlen) & ") - " & abs (getvar (maxplen) - getvar (totlen)) & " chars too much" , osongdata.lyricist )

(VBscript)

Problem: "totlen" always equals "maxplen", "trlen" always equals "maxplen" too...

Probably my own fault, but I would be really glad if someone could help me out of this misery! :(

PS: at the moment it's hard to find regexp documentation, apart from the forum stuff - are you planning to write an "official" Regexp manual? This would save hours of searching for me, and I suppose for a lot of other users too.... :D

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Tue Oct 26, 2010 11:29 am
by ZvezdanD
FunnyFish wrote:I'm having problems with the new SETVAR function.
SetVar(vVarName, vValue) is a custom function which first argument could be a numeric or a string value. That value is a variable name, but not a variable itself. You could write something like SetVar(1, 1234) or SetVar("TrLen", 1234), but not SetVar(TrLen, 1234). So, your expression should be:

Code: Select all

iif (setvar ("totlen", setvar ("trlen", len (osongdata.trackorderstr) ) + iif (getvar ("trlen") > 0, len (" - ") , 0 ) + len( osongdata.artistname ) + len (" - ") + Len( osongdata.title )) > setvar ("maxplen", 64), "Warning:file name exceeds " & getvar ("maxplen") & " characters(" & getvar ("totlen") & ") - " & abs (getvar ("maxplen") - getvar ("totlen")) & " chars too much" , osongdata.lyricist )
However, I have several questions. Why do you have setvar (maxplen, 64) and getvar (maxplen) at all? Why don't you use just 64 instead? Also, instead of len (" - ") you could write just 3 and execution of such preset would be faster.

One more thing, I am not sure that expression setvar ("trlen", len (osongdata.trackorderstr) ) + iif (getvar ("trlen") is much shorter then len (osongdata.trackorderstr) + iif(len (osongdata.trackorderstr), and most probably it would be slower.

By the way, if you write "$&" instead of osongdata.lyricist then you could specify a destination field just by selecting a wanted field from the Into list.

Finally, why do you want to store such text into Lyricist field? Why don't you just choose Keep to Replace or Select to Replace instead of Replace All? Even better, you could use Magic Nodes add-on which would be much faster since it executes SQL to filter out wanted tracks instead of VBScript:

Code: Select all

<Group|Name:Tracks...>\Tracks which length of Track # - Artist - Title exceeds 64 characters|Icon:3|Filter:Length(<Track number>) + CASE WHEN Length(<Track number>) > 0 THEN 3 ELSE 0 END + Length(<Artist>) + 3 + Length(<Title>) > 64
FunnyFish wrote:PS: at the moment it's hard to find regexp documentation, apart from the forum stuff - are you planning to write an "official" Regexp manual? This would save hours of searching for me, and I suppose for a lot of other users too.... :D
I am not sure by "regexp documentation" what do you mean. If you want to know more about Regular Expressions in general, you could find many on-line tutorials and manuals about them on the Internet - one such link is even provided in the first post of this thread.

However, if you are interested about a manual for usage of this add-on, then you should be patient since I have a plan to write it someday.

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Wed Oct 27, 2010 5:35 am
by FunnyFish
Thanks for your quick reply. After quoting the the var names the script works as a breeze.

In reply to yor comments:
However, I have several questions. Why do you have setvar (maxplen, 64) and getvar (maxplen) at all? Why don't you use just 64 instead? Also, instead of len (" - ") you could write just 3 and execution of such preset would be faster.
I am not very interested in fast excution, more in maintainalbe code. Plus, I just wanted to to try out the setvar() function.
One more thing, I am not sure that expression setvar ("trlen", len (osongdata.trackorderstr) ) + iif (getvar ("trlen") is much shorter then len (osongdata.trackorderstr) + iif(len (osongdata.trackorderstr), and most probably it would be slower.
Of course, thx, I added that for debugging purposes - point taken.
By the way, if you write "$&" instead of osongdata.lyricist then you could specify a destination field just by selecting a wanted field from the Into list.
I've just downloaded this version and am trying out the new stuff. But this is a very powerful addition, I think.
Finally, why do you want to store such text into Lyricist field? Why don't you just choose Keep to Replace or Select to Replace instead of Replace All? Even better, you could use Magic Nodes add-on which would be much faster since it executes SQL to filter out wanted tracks instead of VBScript:
Re 1: this was boggling me. I am using 'Keep to replace' and don't want to use the field. But I do need to specify an output field, don't I? Or am I mistaken?
Re 2: I am not experienced in using MN, seems a bit daunting to me :oops: ... But you are of course spot on: the code would not only execute faster, but would be much easier to understand and maintain. I'll look into MN.
However, if you are interested about a manual for usage of this add-on, then you should be patient since I have a plan to write it someday.
Well, I am patient and getting by, thanks to the examples and the forum posts. I indeed meant a 'manual' for your MediaMonkey extension and am hoping that 'someday' will come soon!

Peter aka Funnyfish

Re: RegExp Find & Replace 4.0 w/ 207 presets (2010-05-21)[MM

Posted: Wed Oct 27, 2010 10:40 am
by ZvezdanD
FunnyFish wrote:Re 1: this was boggling me. I am using 'Keep to replace' and don't want to use the field. But I do need to specify an output field, don't I? Or am I mistaken?
You are right, you need to specify the destination field with the Into list, but for Keep to Replace command it doesn't matter which field you would choose if you replace osongdata.lyricist with "$&" as I suggested. It confused me because from your previous post I concluded that you are going to modify Lyricist field for real using Replace command.

By the way, if you want the correct result you need to modify your code since with Joliet you have limit on 64 characters for the filename including the period and extension. So, you should add something like + 1 + Len(oSongData.Path) - InStrRev(oSongData.Path, ".")