Hello,
As title says…
Is there a way to replace the last comma in a field say %artist% to an ampersand &?
Hello,
As title says…
Is there a way to replace the last comma in a field say %artist% to an ampersand &?
This should work:
$set(artist,$rreplace(%artist%,\(.*\)\,\([^\,]+\),\\1 &\\2))
Thanks for reply
Works for artist field with only one feat artist. If there is more than one it will add multiple &
When Picard 2.3 is released, I’ve added some new scripting functions that should allow what you want. Basically, if the length of the multi-value %artists%
tag is greater than 1, split the list into two:%_artists_a%
containing all of the artists except the last using $setmulti(_artists_a,$slice(%artists%,0,-1))
; and the final element as %_artists_b%
using $set(_artists_b,$getmulti(%artists%,-1))
. Then join all of the elements of %_artists_a% with a separator of ‘, ’ and then append ’ & %_artists_b%’ using `$set(my_artists,$join(%_artists_a%,, ) & %_artists_b%).
Alternately, you could reverse the %artist% string using
$set(_reverse_artist,$reverse(%artist%))`, replace the first occurrence of ‘;’ with '& ’ using a regular expression replace, and then again reverse the resulting string.
Note that this is all untested code, and again only applies when Picard 2.3 is released.
EDIT: I also think that making one small change to the solution provided by @outsidecontext will work. The revised line is:
$set(artist,$rreplace(%artist%,\(.*\)\,\([^\,]\$\),\\1 &\\2))
Again, I haven’t tested this.
what if you want to replace underscores in file and folder names with a comma and space?
I currently have $replace(%dirname%%filename%,_,\, )
but in the examples below in renaming, the underscores don’t change any thoughts on how to do this very simple task, please?