Help configuring file renaming and moving

Hi Bob.
I have just (yesterday) discovered picard - have used filebot previously.
Your script looks like it’s an almost perfect fit for my preferences functionally…I would just like to shift a few bits around i.t.o naming conventions/preferences.
The tagging language is obviously new to me, so I would like to ask a few Q’s.
The regex’s revert (by default it seems) to _ for [/:] etc but I see in your $noop bits you have other possibilities (linux system, so Windows compatibility not an issue).
I moved


out of the commented piece in both foreach loops, but the resulting filename still contained “_” in place of “/”
I personally do : → ; but your option is probably better

What is the correct syntax to invoke these…and lastly…
although the filenames do change, the subdir(s) remain unchanged. Which setting do I need to adjust to get everything to change at once?

A big thank you for the amazing work you have done. I would have saved countless hours if I had discovered this years ago!

PS. I don’t see a syntax highlighter/language mode for VScode, do you have/know of one?

That’s because Picard interprets a “/” as a directory separator and therefore it cannot be included in a file name.

To move the files to a new target directory, you must have the “Move files when saving” option enabled.

If you haven’t already done so, I strongly recommend that you review the Picard User Guide to understand the available option settings and usage workflows. There is also a tutorial there on how to develop your own custom file naming script.

@outsidecontext developed one called “Tagger Script Syntax” which is what I use.


Hi Bob.
Thank you for the reply - much appreciated.
I have briefly checked the user guide, but will review it again in depth.

in the above case - if I understand you correctly, the regex below doesn’t do anything (probably why you $noop’d it?)

In the “move” settings, can I use “.” as the destination to just keep the files in current subdir?

Thank you for the syntax - i will locate and load.

Again, my thanks for some amazing work!

Actually, it replaces the slash (/) with a bullet character (•). I disabled it because on my windows system it was being replaced with an underscore to maintin windows compatibility, so no need to do the replacement.

If you want to keep the files in the current directory, you’re actually better off simply disabling (unchecking) the “Move files” option setting.


I like the bullet option! Thanks

When I leave “move” unchecked, the album subdir doesn’t seem to get renamed?

Clearly I have no idea of what you’re trying to do with respect to moving files. You had indicated that you wanted to keep the files in the same directory, which I interpreted as not wanting to move them. Now you’re concerned because they aren’t being moved to a different directory. What exactly are you trying to do?

If you enable “Move Files”, then in the Option settings you need to specify a root directory in which the new file directories will be created (based on your file naming script). I haven’t checked, but I suspect that if you set this root directory to “.” it will use the directory containing the Picard program as the root, which I suspect is not what you want.

Also, this is getting way off topic for this thread. @reosarevok can you please split these last few messages (beginning with @trentmu’s initial message) off into a new thread? Thanks.

I moved this conversation to a new topic.

If you set the target directory to “.” it will be the current location of the file and folders will be created there. This is most definitely not what you want. Instead select the folder in which you want the subfolders to ve created in.


Hi Bob.
I will try to explain better (sorry).
Let’s say I have some albums in a subdir
eg. 3 albums each in subdirs by same artist…

  • subdir
    • “1. Elvis - best of”
      • song1
      • song2
    • “2. Elvis greatest hits”
      • song1
      • song2
    • “Elvis Presley - Live”.
      • song1
      • song2

I would like to achieve (within same subdir - I thought I would move them to “final” genre based location at a later stage)

  • Artist
    • [year] Album
      • Artist - [year] Album - 01 - Song Name

If I leave the “move” unchecked, then the songs themselves get renamed to the correct pattern, but the albums remain unchanged.

To do that, you will need to 1) enable the “Move Files” option; 2) set the Destination directory to the full path to “subdir”; and 3) have your file naming script provide the new part of the path and file name “Artist/[year] Album/Artist - [year] - Album - track number - Song Name”. For example, if your current setup has the songs in “/home/trentmu/Music” as your “subdir”, then you need to set the destination directory to “/home/trentmu/Music”.

In my case I have my source files in subdirectories of a “/home/rdswift/ripped” directory and set the renaming destination directory to “/home/rdswift/Music”. This way I can move my unprocessed files to subdirectories under “/home/rdswift/ripped” (which is also where I have my CD ripper set up to write the files it rips) and work in small batches. As the files are processed, they are moved to subdirectories of the “Music” directory and removed from the “ripped” directory. This way I can easily see which files have yet to be processed. I check the subdirectories and files in the “Music” directory and once I know that the albums have been processed properly, I move the new directories and the renamed files to my nas which is backed up and hosts the collection on my local network using Jellyfin.


Hi Bob. I have done as you recommended, and the album subdirs are now adjusting correctly. Thank you very much for this part!!

I am still not having success with specific characters in the file rename, so if you don’t mind indulging my stupidity just a bit more.
I read this post and it seemed like it was ideal for what I’d like to do, but the “/” still gets replaced with _.

Based on the comment in that post - if I understand correctly - the tags need to be fixed first (otherwise the rename part overrides them anyway), so I put (only) this part into “Scripting” as “My script 1”


$noop( $set(_titleForFilename,$replace(%_titleForFilename%,/,;)) )


$noop( maybe I should be less ambitious and use ; instead of the fancy slash?


and then (only) this part into “File Naming”

$if($eq(%releasetype%,album), Albums/,
  $if($eq(%releasetype%,single), Singles/,
    $if($eq(%releasetype%,ep), EPs/,
      $if($eq(%releasetype%,broadcast), FM/,
        $if($eq(%releasetype%,other), Other/,
          $if($inmulti(%releasetype%,dj-mix), DJ Mix/,
            $if($inmulti(%releasetype%,remix), Remix/,
              $if($inmulti(%releasetype%,soundtrack), OST/,
                $if($inmulti(%releasetype%,live), Live/,
                  $if($inmulti(%releasetype%,mixtape/street), Mixtape/,
                    $if($inmulti(%releasetype%,compilation), Compilation/,)
$if($if2(%_date%,%originalyear%,%originaldate%),[$left($if2(%_date%,%originalyear%,%originaldate%),4)] ,)
$if2(%_artists_album_primary_cred%,%artist%) - 
$if($if2(%_date%,%originalyear%,%originaldate%),[$left($if2(%_date%,%originalyear%,%originaldate%),4)] $if(%albumartist%,%album%,) - ,)
$if($and(%albumartist%,%tracknumber%),$num(%tracknumber%,2) - ,)
$if($if2(%_albumartists%,%artist%,) - ,)%_titleForFilename%

It does seem to use the _varName values since the file gets renamed, and if I look at any particular song that contained a “/” … the tag appears to now have the “corrected/slash” but the renamed file still has the “standardslash”-> _.

If it helps…I DO feel like a bit of an idiot.

Should the whole script be in both scripting/File Naming, or is it OK/correct to put the setting part in Scripting and the filenaming part in File Naming.
I have unchecked “Replace non-ASCII characters” & “Windows compatibility”

On the File Naming Compatibility page in the Options settings, try replacing the underscore in the “Replace directory separators with” option with your revised slash character. You may also have to make sure that the “Replace non-ASCII characters” option is disabled.

Hi again Bob.
Your suggestion appears to be THE perfect solution, but under “options” I don’t seem to have the File Naming Compatibility on my version (std debian 2.6.5 for bullseye).
I thought maybe this was only in the newest version, so I set up a VM using bookworm which installs 2.8.5, but similarly these options aren’t included in that version either?
I have done a few manualy “fixes” within the tags and they DO produce correctly non-ascii named files, so this is definitely the right track

1 Like

Indeed, that option is not yet in the stable release. Will be part of the 2.9 release, which we will release soon.


Thank you - this app is absolutely F*&^%ING AWESOME!!!


I’ve just found this thread whilst trying to get my collection in order and am using the script provided by @rdswift , so many thanks for your hard work. One thing I’ve been left with is a lot of artist folders where one artist has collaborated with another and so I have many folders when in effect the ‘main’ artist is the same. In these instances the additional artist is named in the actual audio file. Is there a way I can modify the script to force Picard to only create a folder for the first ‘main’ artist which will include all albums with everyone he/she/they have collaborated with? This would make things absolutely perfect for me! Many thanks in advance.

If you use the “Additional Artists Variables” plugin, it will make the first artist for both the album artists and the track artist available in variables. Have a look at the documentation for the plugin for more details.

1 Like

Thanks @rdswift for your quick response on this, I hope the community appreciates all you do here! I have the plugin activated but whenever I try and amend your script to give me a single artist folder I end up screwing something up elsewhere. At the moment for example I have somehow managed to disable the [various artists] folder and these albums now go into the V folder instead. I’m not a coder in any way so I must be honest and admit that a lot of this sort of thing goes over my head! I’m trying to learn though, slowly but surely.

Without seeing the script that you’re using (including any changes that have been made), it is pretty much impossible for any of us to identify the problem and suggest a fix.

I actually find this unusual because my file naming script already uses the primary album artist when creating the directory structure. The latest version of the script is available from my repository on GitHub. I suggest that you give that a try and see if it works for you. That way if we need to make tweaks to match your personal preferences, at least we’ll know what we’re starting with.

1 Like

Thanks for all the assistance Bob, I’ve been messing around with your script and decided that I don’t know enough and by changing things I seem to be breaking everything., so have reverted to the original from your GitHub and am working from that.

I’m afraid the ~ before and after the first letter of the artist folder doesn’t work for me, although I seem to have been able to delete that simply by removing that from line 231.

In an ideal world, I would love to amend your script ever so slightly so that artist folders are (first name last name), rather than the existing (last name, first name). I understand why many would want it like that but for my case I’d prefer it not to be. However, moving “The” to the end of the folder name is ideal. My understanding from the script is that amending line 92 to $set(_aSortOnFirstName,1) would achieve this, but I must be missing a change somewhere else I assume?

For albums with multiple artists, I’d also like these to go in the folder of the main artist, not to create a new folder named with every artis, which the current script seems to do.

I’d also really like to remove the soundtrack and various artists folders, so they instead revert to the folder of the main artist, or V for various, and I’m not sure the lines I need to delete to do that.

Ideally I’d also like to add the track artist after track number and before track title, so that would include artists featured at this point rather than at the end of the track… I’m not sure what I need to change to make that happen or if it even is possible?

I hope you can make sense of that! Any advice would be welcome, whilst frustrating at times, I’m enjoying the tinkering!

I’m not sure I would describe your changes as “ever so slightly”… :grinning:

Try this script with the Additional Artists Variables plugin enabled and see if it does what you want:

[$left($if2(%originaldate%,%originalyear%,%date%,0000),4)] %album%/
$pad(%tracknumber%,2,0) %artist% - %title% 

I believe this should be a lot closer, and easier to make any necessary tweaks.

1 Like