Author Topic: multiple search and replace for multiple tracks  (Read 1772 times)

cynflux

  • Jr. Member
  • **
  • Posts: 76
Hello,
I am trying to update a tag in multiple tracks, but the update information is dependent on what is initially in the tag before it is changed.

The tag is Initial Key and the entry will vary from 1A (1B, 2A, 2B, and so on) to 12B.

If the original Initial Key tag entry is 1A, then I would like to replace it with "1A / A♭ Minor".
If the original Initial Key tag entry is 1B, then I would like to replace it with "1B / B Major", and so on.

Is there a way to automate this process with Advanced Search and Replace?

Thank you in advance.



psychoadept

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10656
The additional tagging & reporting tools plugin can do this for you.  Just be sure to test on a few files (or duplicates) to make sure you're getting the result you want.
MusicBee Wiki
Use & improve MusicBee's documentation!

Latest beta patch (3.5)
(Unzip and overwrite existing program files)

redwing

  • Guest
I am also looking for such feature. I'll ask boroda74 to support that with the plugin.

hiccup

  • Hero Member
  • *****
  • Posts: 6088

The tag is Initial Key and the entry will vary from 1A (1B, 2A, 2B, and so on) to 12B.

If the original Initial Key tag entry is 1A, then I would like to replace it with "1A / A♭ Minor".
If the original Initial Key tag entry is 1B, then I would like to replace it with "1B / B Major", and so on.

Is there a way to automate this process with Advanced Search and Replace?

If you only need to have it displayed like that within MusicBee, it might be easier to use a virtual tag for that.
Then you wouldn't need to re-write tags at all.

e.g.:
$IsNull(<Initial Key>,,$Replace($Replace(<Initial Key>,1A,"A♭ Minor"),1B,"B Major"))


It's not difficult to add the additional required replacements.

Just paste:
$Replace(
right behind the second comma

and paste the values that you want to be replaced just before the second-last parenthesis at the end, using this syntax:
),2A,"E♭ Minor"
(to replace 2A with E♭ Minor)

So the next step after having created:
$IsNull(<Initial Key>,,$Replace($Replace(<Initial Key>,1A,"A♭ Minor"),1B,"B Major"))

would result in:

$IsNull(<Initial Key>,,$Replace($Replace($Replace(<Initial Key>,1A,"A♭ Minor"),1B,"B Major"),2A,"E♭ Minor"))

etc.
Last Edit: February 27, 2018, 05:30:26 PM by hiccup

cynflux

  • Jr. Member
  • **
  • Posts: 76
Thank you for all the responses.
I am having limited success with Advanced Search and Replace.
It can't tell the difference between 1A and 11A, apparently.
It seems I am getting a major program error every other time I select Advanced Search and Replace option.
I'll post the error when it happens again.

cynflux

  • Jr. Member
  • **
  • Posts: 76
MusicBee v3.1.6590.32668 (Win6.1), 28 Feb 2018 23:12:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'AdvancedSearchAndReplacePlugin'.
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.Form.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at MusicBeePlugin.PluginWindowTemplate.display(Boolean modalForm)
   at MusicBeePlugin.Plugin.asrEventHandler(Object sender, EventArgs e)
   at #=zOctyNPMpBP9L_Vg0tXadst$vbvh5.#=zlHThRIc=(Object #=zjHM6LIc=, EventArgs #=zK_CBPjQ=)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

redwing

  • Guest
I am having limited success with Advanced Search and Replace.
It can't tell the difference between 1A and 11A, apparently.

My guess is you didn't use word boundary in your search pattern: https://www.regular-expressions.info/wordboundaries.html

Also post the error on the plugin thread along with what exactly you did at that time.

hiccup

  • Hero Member
  • *****
  • Posts: 6088
It seems you are not interested in using a virtual tag for this. And looking at my suggestion, I see that 1A vs. 11A would indeed pose a problem there too.
As an exercise, and perhaps for others stumbling onto this thread, I adjusted and completed the formula. This should work:

Code
$IsNull(<Initial Key>,,$Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace($Replace(<Initial Key>,11,C),12,D),1A,"A♭ Minor"),2A,"E♭ Minor"),3A,"B♭ Minor"),4A,"F Minor"),5A,"C Minor"),6A,"G Minor"),7A,"D Minor"),8A,"A Minor"),9A,"E Minor"),10A,"B Minor"),CA,"F♯ Minor"),DA,"D♭ Minor"),1B,"B Major"),2B,"F♯ Major"),3B,"D♭ Major"),4B,"A♭ Major"),5B,"E♭ Major"),6B,"B♭ Major"),7B,"F Major"),8B,"C Major"),9B,"G Major"),10B,"D Major"),CB,"A Major"),DB,"E Major"))
Last Edit: March 01, 2018, 12:23:21 PM by hiccup


boroda

  • Hero Member
  • *****
  • Posts: 3662
now its possible with new asr preset (this preset can be used as function as well). enter the following string in 'custom text 1' field:

11\C|12\D|1A\A♭ Minor|2A\E♭ Minor|3A\B♭ Minor|4A\F Minor|5A\C Minor|6A\G Minor|7A\D Minor|8A\A Minor|9A\E Minor|10A\B Minor|CA\F♯ Minor|DA\D♭ Minor|1B\B Major|2B\F♯ Major|3B\D♭ Major|4B\A♭ Major|5B\E♭ Major|6B\B♭ Major|7B\F Major|8B\C Major|9B\G Major|10B\D Major|CB\A Major|DB\E Major
Last Edit: March 01, 2018, 06:31:10 PM by boroda74

cynflux

  • Jr. Member
  • **
  • Posts: 76
Redwing, you were right. I needed a word boundary in the search pattern.


Boroda74, This is fantastic!
I did not realize you could also do functions.


11\C|12\D

CB\A Major|DB\E Major

Thank you all so much.