This is not the easiest script, so let’s do it part by part and then assemble the final script:
There is a easy way, that does somewhat what you want, but without the brackets:
$swapprefix(%albumartist%)
This will result in “Beatles, The”. But you want the brackets, so try this:
$set(_albumartistprefix,$rsearch(%albumartist%,^\(The|A\)\\s+))
$if(%_albumartistprefix%,$rreplace(%albumartist%,^\(%_albumartistprefix%\)\(.*\),\\2 \(\\1\)),%albumartist%)
For easier usage later we create two hidden variables %_albumartist%
and %_artist%
we use for naming:
$set(_nameprefixes,The|A)
$set(_albumartistprefix,$rsearch(%albumartist%,^\(%_nameprefixes%\)\\s+))
$set(_albumartist,$if(%_albumartistprefix%,$rreplace(%albumartist%,^\(%_albumartistprefix%\)\(.*\),\\2 \(\\1\)),%albumartist%))
$set(_artistprefix,$rsearch(%artist%,^\(%_nameprefixes%\)\\s+))
$set(_artist,$if(%_artistprefix%,$rreplace(%artist%,^\(%_artistprefix%\)\(.*\),\\2 \(\\1\)),%artist%))
Not sure about some details you want, but try this one with the “Feat. Artists in Titles” installed:
%_artist%-%title%-%tracknumber% - %_bitrate% - %originaldate%
Let’s save this as a variable %_file%
for better readability later:
$set(_file,%_artist%-%title%-%tracknumber% - %_bitrate% - %originaldate%)
You can still tweak some details, e.g. should track number be with leading zero or not. If it should use $num(%tracknumber%,2)
instead of just %tracknumber%
. Also %originaldate%
is the original date of the release. We don’t have this for individual recordings. There was some discussion about this recently here. In theory it would be possible to get this with a plugin, in practice it would likely be very slow to do so.
%_albumartist%-%album%-\(%date%\)$if($gt(%totaldiscs%,1),-CD%discnumber%)
Again let’s save this as a variable %_album%
for better readability later:
$set(_album,%_albumartist%-%album%-\(%date%\)$if($gt(%totaldiscs%,1),-CD%discnumber%))
The artist folder and subfolder:
%_albumartist%/%_album%/
But wou want different behavior for non-album tracks, so we add the %_album%/
part only, if album is not “[non-album tracks]”:
%_albumartist%/$if($ne(%album%,[non-album tracks]),%_album%/)
So a different folder name for VA releases. We get this by replacing the %_albumartist%/
part above with $if($eq(%compilation%,1),_VA,%_albumartist%)/
to get:
$if($eq(%compilation%,1),_VA,%_albumartist%)/$if($ne(%album%,[non-album tracks]),%_album%/)
Another case. So we use $inmulti(%releasetype%,soundtrack)
to detect soundtracks. How exactly to combine this depends whether soundtracks take precedence over VA and single artist releases. The following assumes you want all your soundtracks under _ST, even if it is a soundtrack by only a single artists:
$if($inmulti(%releasetype%,soundtrack),_ST,$if($eq(%compilation%,1),_VA,%_albumartist%)/$if($ne(%album%,[non-album tracks]),%_album%/))
This is our script to name the folders.
The final scripting
Now we have the folder script, the actual file name and some helper variables to hold the more complex scripting. First add the helper variables to Options > Scripting as the following script (with $noop
I just set some comments):
$noop(Move name prefixes The and A to the end in brackets. You can add additional prefixes separated by | if you want to.)
$set(_nameprefixes,The|A)
$set(_albumartistprefix,$rsearch(%albumartist%,^\(%_nameprefixes%\)\\s+))
$set(_albumartist,$if(%_albumartistprefix%,$rreplace(%albumartist%,^\(%_albumartistprefix%\)\(.*\),\\2 \(\\1\)),%albumartist%))
$set(_artistprefix,$rsearch(%albumartist%,^\(%_nameprefixes%\)\\s+))
$set(_artist,$if(%_artistprefix%,$rreplace(%artist%,^\(%_artistprefix%\)\(.*\),\\2 \(\\1\)),%artist%))
$noop(Set album name for renaming)
$set(_album,%_albumartist%-%album%-\(%date%\)$if($gt(%totaldiscs%,1),-CD%discnumber%))
$noop(The actual file name for renaming)
$set(_file,%_artist%-%title%-%tracknumber% - %_bitrate% - %originaldate%)
Then in Options > File Naming we have to assemble the final naming script by combining the folder naming with the file naming:
$if($inmulti(%releasetype%,soundtrack),_ST,$if($eq(%compilation%,1),_VA,%_albumartist%)/$if($ne(%album%,[non-album tracks]),%_album%/))%_file%
Disclaimer: I have not tested this Please try carefully, and let us know if you need some tweaking. But this should be a good start.