Tagging script
- http://docs.puddletag.net/source/function.html
- http://docs.puddletag.net/source/scripting.html
- http://docs.puddletag.net/source/tags.html
Latest
New beta regex formatting rule below!
Now old formatting rule: Puddletag file spaces to underscores + albumartist ifs:
$replace($validate($if(%albumartist%,%albumartist%,%artist%),,’`'”-/\|;:*?!&\[]{}<>,.)," ","_")/$replace($validate($if(%albumartist%,%albumartist%,%artist%),,’`'”-/\|;:*?!&\[]{}<>,.)," ","_")-%year%-$replace($validate(%album%,,’`'”-/\|;:*?!&\[]{}<>,.)," ","_")/$replace($validate($if(%albumartist%,%albumartist%,%artist%),,’`'”-/\|;:*?!&\[]{}<>,.)," ","_")-%year%-$replace($validate(%album%,,’`'”-/\|;:*?!&\[]{}<>,.)," ","_")-$num(%track%,2)$if(%albumartist%,-$replace($validate(%artist%,,’`'”-/\|;:*?!&\[]{}<>,.)," ","_"),)-$replace($validate(%title%,,’`'”-/\|;:*?!&\[]{}<>,.)," ","_")
Be careful when copying and pasting the above - a new line character might be added to the end.
Produces directory path and filenames like this:
/media/3tb/media/music/FLAC/Decapitated/Decapitated-2000-04-17-Winds_of_Creation/Decapitated-2000-04-17-Winds_of_Creation-05-Decapitated-The_Eye_of_Horus.flac
$validate(%title%,,’`'”-/\|;:*?!&\[]{}<>,.)
Cannot validate away ( or ) with the above method. Two regexs instead of validate and replace would allow changing ( and ). One for removing, one for underscores.
Functions cannot be applied across directory boundaries.
$regex(text, regex, repl, matchcase=0) Replaces all occurrences of regex with repl in text. text: text to search, eg. %artist% regex: regular expression to use as the search eg. jay.* repl: Text to replace all matches of regex with. Can be pattern ex $lower($1), but has to be quoted like in “$lower($1)” otherwise any scripting functions used will be run before the regular expression is evaluated. matchcase: Defaults to 0. If 1, will have case-sensitive matching. 's/ /_/g' $regex(,\s,_) chars to remove: ’`'”-*?!&/|\()[]{}<>;:,. unescaped: $regex(,’`'”-*?!&/|\()[]{}<>;:,.,) regex control chars: [\^$.|?*+(){}
not used: regex to make string filesystem safe?: ^(/)?([^/\0]+(/)?)+$
escaped: $regex(,’`'”-*\?!&/\|\\\(\)\[]\{\}<>;:,\.,) within removal of spaces $regex($regex(,’`'”-*\?!&/\|\\\(\)\[]\{\}<>;:,\.,),\s,_) | |
$if(%albumartist%,%albumartist%,%artist%)/ $if(%albumartist%,%albumartist%,%artist%)-%year%-%album%/ $if(%albumartist%,%albumartist%,%artist%)-%year%-%album%-$num(%track%,2)$if(%albumartist%,-%artist%,)-%title%
beta final?: $regex($regex($if(%albumartist%,%albumartist%,%artist%),’`'”-*\?!&/\|\\\(\)\[]\{\}<>;:,\.,),\s,_)/$regex($regex($if(%albumartist%,%albumartist%,%artist%)-%year%-%album%,’`'”-*\?!&/\|\\\(\)\[]\{\}<>;:,\.,),\s,_)/$regex($regex($if(%albumartist%,%albumartist%,%artist%)-%year%-%album%-$num(%track%,2)$if(%albumartist%,-%artist%,)-%title%,’`'”-*\?!&/\|\\\(\)\[]\{\}<>;:,\.,),\s,_) to test ^ !!!
Issues(?):
- double __?
- remove accidental trailing whitespace?
Remember to:
- avoid blank years
- avoid blank album/artist names
- check if some album artists should be "Various Artists" or a performer/DJ/curator name
Older crap
basic formatting tests (see bottom for final);
Puddletag directory spaces to _: $replace($validate(%artist%,,’`'/\*?;”|:)," ","_")/$replace($validate(%artist%,,’`'/\*?;”|:)," ","_")-%year%-$replace($validate(%album%,,’`'/\*?;”|:)," ","_") Puddletag file spaces to _: $replace($validate(%artist%,,’`'/\*?;”|:)," ","_")-%year%-$replace($validate(%album%,,’`'/\*?;”|:)," ","_")-$num(%track%,2)-$replace($validate(%title%,,’`'/\*?;”|:)," ","_") Puddletag directory remove spaces: $validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|: )/$validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|: )-%year%-$validate(%album%,,’`'/\*?;”|: )/ Puddletag file remove spaces: $validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|: )-$if($neql(%artist%,%albumartist%),%artist%-,)%year%-$validate(%album%,,’`'/\*?;”|: )-$num(%track%,2)-$validate(%title%,,’`'/\*?;”|: ) $validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|: )-$if($neql(%artist%,%albumartist%),%artist%-,)%year%-$validate(%album%,,’`'/\*?;”|: )-$num(%track%,2)-$validate(%title%,,’`'/\*?;”|: ) redo: %artist%/%artist%-%year%-%album%/ %artist%-%year%-%album%-%track%-%title% %albumartist%/%albumartist%-%year%-%album%/ %albumartist%-%year%-%album%-%track%-%artist%-%title% $if(%albumartist%,%albumartist%,%artist%)/$if(%albumartist%,%albumartist%,%artist%)-%year%-%album%/$if(%albumartist%,%albumartist%,%artist%)-%year%-%album%-%track%$if(%albumartist%,-%artist%,)-%title% $validate(,,’`'”-/\|;:*?!&\[]<>,.)
Schema: albumartist = various artists compilation album. An if to see if albumartist and artist is different would fail for compilations including a track by the album artist.
Final:
Puddletag file remove spaces + albumartist ifs: $validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|: -&\[],.)/$validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|: -&\[],.)-%year%-$validate(%album%,,’`'/\*?;”|: -&\[],.)/$validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|: -&\[],.)-%year%-$validate(%album%,,’`'/\*?;”|: -&\[],.)-$num(%track%,2)$if(%albumartist%,-$validate(%artist%,,’`'/\*?;”|: -&\[],.),)-$validate(%title%,,’`'/\*?;”|: -&\[],.)
Produces directory path and filenames like this:
/media/3tb/media/music/FLAC/Decapitated/Decapitated-2000-04-17-WindsofCreation/Decapitated-2000-04-17-WindsofCreation-05-Decapitated-TheEyeofHorus.flac
New final:
Puddletag file spaces to underscores + albumartist ifs: $replace($validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|:-&\[],.)," ","_")/$replace($validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|:-&\[],.)," ","_")-%year%-$replace($validate(%album%,,’`'/\*?;”|:-&\[],.)," ","_")/$replace($validate($if(%albumartist%,%albumartist%,%artist%),,’`'/\*?;”|:-&\[],.)," ","_")-%year%-$replace($validate(%album%,,’`'/\*?;”|:-&\[],.)," ","_")-$num(%track%,2)$if(%albumartist%,-$replace($validate(%artist%,,’`'/\*?;”|:-&\[],.)," ","_"),)-$replace($validate(%title%,,’`'/\*?;”|:-&\[],.)," ","_")
How does evaluation work? test:
$replace($validate($if(%albumartist%,%albumartist%,%artist%)/$if(%albumartist%,%albumartist%,%artist%)-%year%-%album%/$if(%albumartist%,%albumartist%,%artist%)-%year%-%album%-%track%$if(%albumartist%,-%artist%,)-%title%,,’`'/\*?;”|:-&\[],.)," ","_")
Ah, evaluation stops at directory slashes.
Issues(?):
- double __?
- remove accidental trailing whitespace?
- paren brackets