Closed michealespinola closed 9 months ago
string[] tagsToProcess = { "ALBUM" };
should work.
Please paste the whole script source code, and the tag value that should be changed.
Thanks.
"ALBUM", quoted and in all capital letters works. I truly could have sworn that I tried that, but it is clearly working when I test it now.
For reference sake, this is the 'Search & Replace.csx
' code:
// This script replaces all occurrences of a specified string in tags value with another specified string
using System.Linq;
using Metatogger.Data;
// enter what you want to search in changeThis (cannot be left empty)
string changeThis = "Ghost";
// enter here what you want to enter (empty string or null will simply remove changeThis)
string toThat = "Boast";
// enter tags name to process => eg. { "TAGNAME1", "TAGNAME2", TagName.TrackNumber }
// leave the array empty to process all tags => { }
string[] tagsToProcess = { "ALBUM" };
foreach (var file in files)
foreach (var tag in file.GetAllTags().Where(kvp => tagsToProcess.Length == 0 || tagsToProcess.Contains(kvp.Key)))
foreach (string tagValue in tag.Value)
file.SetTagValue(tag.Key, tagValue, tagValue.Replace(changeThis, toThat));
Thank you very much for your reply, and sorry for seemingly wasting your time with something that I should have caught myself.
Great. Notice that "ALBUM" == TagName.Album
, but there is no IntelliSense in Metatogger, unfortunately.
Metatogger 7.4.0.1 - 64 bits .NET 8.0.0 Microsoft Windows NT 10.0.19045.0
Working with the example
Search & Replace.csx
script, it works when following the example to "leave the array empty to process all tags => { }" is left empty. However, specifying specific tags does not seem to work.string[] tagsToProcess = { };
string[] tagsToProcess = { "Album" };
There is no error message when using
{ "Album" }
to specify only performing the search and replace against the "Album" tag. Letter case (UPPER, lower, Proper) does not seem to have an effect. I have confirmed through testing that the search and replace will work when the array is left empty. It does not work when the array is populated.The following error is returned when trying to specify the tag without quotes:
I thought this used to work, but it's been a long time since I have tried to specify specific tags. My apologies if I have missed or forgotten something here.