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

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

ed.j
Posts: 78
Joined: Thu May 19, 2011 1:44 pm

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

Post by ed.j » Mon May 27, 2019 12:19 pm

Hopefully someone can give me a hand with this - I'm trying make a script that swaps A and B but only if B exists (ie B is not empty).

Swapping A and B is a preset but I'll be if I understand Reg expressions and where to put the "if B exists" part!

Can anyone give me a pointer please?

Erwin Hanzl
Posts: 266
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

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

Post by Erwin Hanzl » Wed May 29, 2019 12:44 pm

' A simple script that swaps the content of Title and Artist fields of selected tracks
' DEMO

Code: Select all

  Set list = SDB.SelectedSongList  
  if list.count<1 then exit sub
  For i=0 To list.count-1
    Set itm = list.Item(i)
    A = itm.Title
    B = itm.ArtistName
    if B<>"" then                   'String is Not Null And Not Empty
    	itm.Title = B
    	itm.ArtistName = A
    end if
  Next
  list.UpdateAll
:D MMW 4.1.25.1885 GOLD Beta :D Meine Einstellungen
:-? MMA 1.3.5.0853 Beta auf Huawei Mate 20 Pro (USB-Kabel-Sync)
:D FindCurrentPlayingTrack 1.3.2 :D Lyrics and Comment Viewer 2.2.0.0 :D CustomFieldsTagger 1.0.3.0 :D Discogs Tagger 5.6.8
:D WIN 10 Pro-1903-64 Bit -- Windows-Defender mit Echtzeitschutz

ed.j
Posts: 78
Joined: Thu May 19, 2011 1:44 pm

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

Post by ed.j » Mon Jun 03, 2019 4:26 pm

Erwin Hanzl wrote:
Wed May 29, 2019 12:44 pm
' A simple script that swaps the content of Title and Artist fields of selected tracks
' DEMO

Code: Select all

  Set list = SDB.SelectedSongList  
  if list.count<1 then exit sub
  For i=0 To list.count-1
    Set itm = list.Item(i)
    A = itm.Title
    B = itm.ArtistName
    if B<>"" then                   'String is Not Null And Not Empty
    	itm.Title = B
    	itm.ArtistName = A
    end if
  Next
  list.UpdateAll
champion! thanks

cokehearth
Posts: 18
Joined: Thu Aug 24, 2017 6:13 am

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

Post by cokehearth » Mon Jun 10, 2019 5:57 am

I'm driving myself mad trying to figure this one out.

I'm trying to set "Custom 4" field to display the TOTAL number of tracks for an entire album - and not just on the one disc.

E.g.

If Disc 1 has 10 tracks, and Disc 2 has 15, I would want to Custom 4 to display "25".

Is there any way to display this?

And optionally, to make the number be at least four numbers long? (e.g. 0025 instead of 25)?

Many thanks.

UPDATE:

I figured out getting the total number of tracks:

SQLQuery("SELECT Count(CAST(TrackNumber AS integer)) FROM Songs WHERE IDAlbum = " & oSongData.Album.ID & " GROUP BY IDAlbum")

All I need now is to find out how I ensure the result comes out as a four-figure number?

Erwin Hanzl
Posts: 266
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

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

Post by Erwin Hanzl » Mon Jun 10, 2019 12:30 pm

strgVar=right(10000+ResultFromSQL,4)
:D MMW 4.1.25.1885 GOLD Beta :D Meine Einstellungen
:-? MMA 1.3.5.0853 Beta auf Huawei Mate 20 Pro (USB-Kabel-Sync)
:D FindCurrentPlayingTrack 1.3.2 :D Lyrics and Comment Viewer 2.2.0.0 :D CustomFieldsTagger 1.0.3.0 :D Discogs Tagger 5.6.8
:D WIN 10 Pro-1903-64 Bit -- Windows-Defender mit Echtzeitschutz

cokehearth
Posts: 18
Joined: Thu Aug 24, 2017 6:13 am

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

Post by cokehearth » Wed Jun 12, 2019 3:53 am

Erwin Hanzl wrote:
Mon Jun 10, 2019 12:30 pm
strgVar=right(10000+ResultFromSQL,4)
Works beautifully!

Many thanks, Erwin!!

Erwin Hanzl
Posts: 266
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

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

Post by Erwin Hanzl » Wed Jun 12, 2019 11:37 am

Bingo
Thanks for the feedback.
It is always nice to know if suggestions could be implemented

You could also try to build your SQL query instead of "ResultFromSQL"
:D MMW 4.1.25.1885 GOLD Beta :D Meine Einstellungen
:-? MMA 1.3.5.0853 Beta auf Huawei Mate 20 Pro (USB-Kabel-Sync)
:D FindCurrentPlayingTrack 1.3.2 :D Lyrics and Comment Viewer 2.2.0.0 :D CustomFieldsTagger 1.0.3.0 :D Discogs Tagger 5.6.8
:D WIN 10 Pro-1903-64 Bit -- Windows-Defender mit Echtzeitschutz

Post Reply