I'm sorry to ask an other question yet, but is there a way to replace a particular character in every title/album/artist of the whole library ?
The problematic character is ` which I'd like to replace by '
I wanted to ask someone here before I make any changes as it may be quite a destructive operation if I don't know exactly what I'm doing.
I gathered some clues here and there but I'm afraid I'm now stuck:
edit command of operon was a possible start but I don't know if I can easily batch process the whole library based on a single character inside a string.Is there a straightforward solution to this issue?
Thanks in advance
Generally best to use the Python Console plugin(s) for this. You have access to as much of the library as you right click on before running it.
You can then use for s in sdict to iterate through the songs, for t in s.realkeys() to go through all the real tags, s[t] to get the value of a tag and s.write() to write the song back if any tags are modified.
If this isn't enough then I suggest writing / requesting a songsmenu plugin.
I finally managed to make it work thanks to your advices,
I went for a quick code with the Python Console Plugin and everything went smoothly in 2 seconds...
Here's my code for those who are looking for something similar:
import string
for s in sdict:
for t in s.realkeys():
if t in ['title']:
if '’' in s[t]:
s[t] = string.replace(s[t], '’', '\'', 6)
else:
continue
else:
continue
s.write()
I'm not much of a programmer so it might not be the most well-optimized piece of code but it works--
The 6 inside the replace tool is arbitrary, I figured there would be less than 6 ' inside a song title but one may choose to raise the value, thus avoiding some complications.
Thanks again for your help!
That would be a nice addition for a plugin indeed, even though it's only about aesthetic...
Good stuff, glad it worked. FYI that can be reduced / made faster (notably: only write if you've changed something), e.g. something like:
for s in sdict:
for t in (set(s.realkeys()) & {'title'}):
if '’' in s[t]:
s[t] = s[t].replace("’", "'", 6)
s.write()
Thank you for that, this seems more elegant indeed.
Great. Closing ticket.
Most helpful comment
Good stuff, glad it worked. FYI that can be reduced / made faster (notably: only write if you've changed something), e.g. something like: