Help - Search - Members - Calendar
Full Version: Scripting Troubles
Hydrogenaudio Forums > Hosted Forums > foobar2000 > General - (fb2k)
Ignite339
Hello all. I was up all night brainstorming ideas on how to successfully create a rename string in which all artists that don't begin with A-Z are put into a starting folder called '0-9'. I tried doing $if3, $select, and others all to no avail. Has anyone thought of a solution to this?
ojdo
An untested idea:
CODE
$ifgreater($len($replace($upper($left(%artist%,1)),A,,B,,C,,[...]Z,)),0,'0-9','A-Z')

Any more elegant ways to do that?
Frank Bicking
This expression returns "0-9" if the first character of the artist is numeric:

CODE
$ifgreater(1$cut(%artist%,1),9,0-9,%artist%)
foosion
The following code returns "0-9" for all artists that don't start with A-Z (or an umlaut/accented character) and the uppercase ASCII representation of the starting letter otherwise (A for Ä, â, à, ...).
CODE
$if($strchr(ABCDEFGHIJKLMNOPQRSTUVWXYZ,$put(F,$upper($ascii($cut(%artist%,1))))),
$get(F),
0-9)

If you want "A-Z" instead of the actual letter, just replace $get(F) with A-Z. You can also replace the $put() call with its second argument. It would then look like this:
CODE
$if($strchr(ABCDEFGHIJKLMNOPQRSTUVWXYZ,$upper($ascii($cut(%artist%,1)))),
A-Z,
0-9)

(By the way, the variable name F is for First).
Ignite339
EDIT: I've got it all figured out! here's the script:

CODE
$if($strcmp($left(%artist%,4),The ),$if($strchr(ABCDEFGHIJKLMNOPQRSTUVWXYZ,$cut($right(%artist%,$sub($len(%artist%),4))', 'The,1)),$upper($cut($right(%artist%,$sub($len(%artist%),4))', 'The,1)),'0-9'),$if($strchr(ABCDEFGHIJKLMNOPQRSTUVWXYZ,$cut(%artist%,1)),$upper($cut(%artist%,1)),'0-9'))


It was my first try of the day, and it worked! I'm so relieved now. Thanks to all the helpers, especially foosion.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.