Adding profile to custom tag for each track

I did get it working, here’s what worked in case anyone is trying to do something similar:

$set(source,$if2(%source%,$substr(%_dirname%,X,$add(X,$find($substr(%_dirname%,X),\)))))

Replace ‘X’ with the number of characters in the UNC path before the name of the folder that you want to use as the tag. The formula uses substrto just grab the folder name I wanted, with the first substr number being the number of characters to skip over to get to the beginning, and then searching the remaining characters for a ‘\’ to determine the length of the folder name, and then adding the beginning length and the folder length to get the second substr number. If a source tag already exists, it leaves it alone, if not, it creates it with the derived value.

As an example, if I have a folder at \\TheMachine\Media\Music\ToProcess where I put my music to be processed, and have subfolders called Amazon, Bandcamp, Deezer, etc then I would set X in the script to 34 which is the number of characters leading up to the source folders. The formula would then return Amazon, Bandcamp or Deezer depending on the folder the tracks were in and would set a tag called source containing that as the value.

1 Like