Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Title formatting - character removal with $replace (Read 2216 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Title formatting - character removal with $replace

Hi all,

I've checked the title formatting help page and this thread, and I think I'm on the right lines ...
I've got a string and want to remove a range of characters that may or may not exist in the string.
Here's what I've got and to make things easier (for me at least, I've added a '0' where later nothing will be, so for example:

$replace(happy,pp,) will look like this (purely so it's easier to read, obviously I'm not doing this with foobar2000):
$replace(happy,pp,0) which should give "ha00y" and when I remove the 0's it will give me "hay".

Okay, here's my code:

Code: [Select]
$puts(out1,$lower(%album%)\$lower(%artist%_%title%))
$puts(out2,$replace($get(out1),?,0,!,0,-,0,',0,,,0,[,0,],0,(,0,),0, ,0))
$trim($get(out2))

Here's the characters I want to remove:

Code: [Select]
? ! - ' , [ ] ( ) and " " (spaces)

So later I'll just delete the 0's ...

Code: [Select]
$puts(out1,$lower(%album%)\$lower(%artist%_%title%))
$puts(out2,$replace($get(out1),?,,!,,-,,',,,,,[,,],,(,,),, ,))
$trim($get(out2))

The problem is this isn't working. Also if these characters aren't in the string what happens? (I assume they're ignored?)
Can someone tell me what I'm doing wrong?

Any help greatly appreciated.
Thanks.

C.
PC = TAK + LossyWAV  ::  Portable = Opus (130)

Title formatting - character removal with $replace

Reply #1
Characters which are part of the title formatting syntax need to be enclosed in apostrophes.

Those characters are: ( ) [ ] % $ , '

A simple example:

Code: [Select]
$replace(%title%,'(',0,')',0,'',0)

'' denotes a single apostrophe.

Title formatting - character removal with $replace

Reply #2
Excellent. Big thanks Frank, that's very cool!!   

Final string:
Code: [Select]
$puts(a1,$replace(%album%,$substr(%album%,$strchr(%album%,-),$strchr(%album%,-)),_%date%_))
$puts(out1,$lower($get(a1))\$lower(%artist%_%title%))
$puts(out2,$replace($get(out1),?,,!,,-,,'',,',',,'[',,']',,'(',,')',, ,))
$trim($get(out2))

C.
PC = TAK + LossyWAV  ::  Portable = Opus (130)

Title formatting - character removal with $replace

Reply #3
I have one more question in regard to this:

Is "$stripprefix(x)" or "$stripprefix(x,prefix1,prefix2,...)" a relatively new function?
I'm using 0.9.4.3 and it comes up with unknown function. Did it used to be called something else?

Thanks again for any help.

C.
PC = TAK + LossyWAV  ::  Portable = Opus (130)


 

Title formatting - character removal with $replace

Reply #5
Thanks smkk.
0.9.5.3 onwards.

C.
PC = TAK + LossyWAV  ::  Portable = Opus (130)