Podcast archive Action in need of suggestions

I'm creating an Action to apply to newly recorded content that will become podcasts. I'm trying to make the Action as fully automatic and fool-proof as possible, so that files/directories can't be renamed in the wrong way, even if the Action is run multiple times.

Since posting my last thread I've decided on saving the timestamp to a tag, rather than relying on the File Creation Date, which can change.

Ideally what I'd like my Action to perform (dates based on saved tag, top date represents directory):


  • 2012.05.31_John_Doe [original].flac
  • 2012.05.31_John_Doe-2 [original].flac
  • 2012.05.31_John_Doe.mp3
  • 2012.05.31_John_Doe-2.mp3
  • 2012.06.01_Paul_Smith.mp3
Directory is named after the earliest timestamp in the folder (the last Mp3 is cut from one of the FLACs the following day, which is why it's timestamp is different).

What my Action already does: (will update when finished)

1. Initially the folder is named '_LatestRip' and the files ripped from the original recording CD are saved there (a FLAC and MP3 of each main recording, with generic 'No Artist' filenames/tags).

2. I first manually enter the Artist name for FLAC and MP3 tracks.

3. Running the Action clears the generic tags, then fills in some static tags like 'Album' and 'Genre', etc.

4. It then saves the File Creation Datetime timestamp to the 'ReleaseTime' tag, before reformatting it to the iTunes format (YYYY-MM-DDThh:mm:ssZ).

5. The Filename, Year, and Directory names are then created based on the 'ReleaseTime' tag.

6. Whitespaces are then converted to underscores, and Flac files have the suffix '[original]' appended to the end of their filename.

What I still need my Action to do:

1. The Action initially removes some existing generic tags, but when running the Action a second time on the same files I need the Action to keep the tags I've manually entered (like 'Title', 'Genre').

IE: If the field matches the exact string "Audio Track 1" then remove it, otherwise keep existing content.

2. On some days there may be two seperate recordings by the same host, so I'm looking for a way to add a '-2' to the end of these, but leave the first file without the suffix (or at least when there is only one file by the same artist).

IE: If two or more files exist with the same date and the same Artist then add a '-2' (etc) to the most recent filename based on the datetime in the 'ReleaseTime' tag. This would be a per-Artist, per-date counter.

I've decided the above feature is not feasible for Mp3Tag to handle (yet), as it currently requires too many unnecessary steps to accomplish in an Action. See Post #9 for the simpler compromise.

3. The date section of the filename currently looks like '2012-05-31_Artist_Name.mp3', but ideally it should be with periods not dashes. This could be done by replacing all dashes with periods, except I want to use a dash for the suffix numbering (see above).

4. Lastly, I'm lookng for a way to name the directory after the earliest timestamp in the folder [no idea how to achieve this]. Also, currently the directory name is a little messed up, '2012.05.31T105546Z' and it should be '2012.05.31'.

My Action in full: (old code, will update when finished)

Action: Remove fields
Fields to remove: Title;Album;Track;Genre;Year;Length

Action: Format value
Field: Album
Format string: Example Album Name

Action: Format value
Field: Genre
Format string: Podcast

Action: Format value
Field: Podcast
Format string: 1

Action: Format value
Field: Releasetime
Format string: $if2(%releasetime%,%_file_create_datetime%)

Action: Format value
Field: Releasetime
Format string: $ifgreater($strstr(%releasetime%,PM),0,$replace(%releasetime%,
1:,T13:, 2,T14, 3,T15, 4,T16, 5,T17, 6,T18, 7,T19, 8,T20, 9,T21, 10,T22, 11,T23,
PM,Z, ,T),$replace(%releasetime%, 12,T00, AM,Z, ,T))

Action: Replace with Regular Expression
Regular Expression: ^(\d\d?)\/(\d\d?)\/(\d\d\d\d)T(\d\d?)
Replace matches with: $3-$num($1,2)-$num($2,2)T$num($4,2)

Action: Format value
Field: _Filename
Format string: $left(%releasetime%,10)

Action: Format value
Field: Year
Format string: $left(%releasetime%,4)

Action: Format value
Field: _Directory
Format string: $regexp(%releasetime%,(\d\d\d\d)-(\d\d)-(\d\d),$1.$3.$2)

Action: Format value
Field: _Filename
Format string: $if(%artist%,%_filename% %artist%,%_filename%)

Action: Format value
Field: _Filename
Format string: $replace(%_filename%,' ',_)

Action: Format value
Field: Comment
Format string: %podcastdesc%

Thanks to this superb forum I'm half the way there :laughing: , and apologies for the rather lengthy post :blush:.

Why do you want to run the same actiongroup twice?
You can run two actionsgroups independent from each other.

You can use something like this to remove a tag-field ...
Action: Format value
Formatstring: %DUMMY%

You can use something like this to keep a tag-field ...
Action: Format value
Formatstring: $if2(%ANY_FIELD_NAME%,%DUMMY%)

You can use something like this to keep a tag-field if there is some special content ...
Action: Format value
Formatstring: $if($eql(%ANY_FIELD_NAME%,'Audio Track 1'),%ANY_FIELD_NAME%,%DUMMY%)

You can create two columns "File Mod DT" and "File Mod DT Raw".
Name: File Mod DT
Value: %_file_mod_datetime%
SortBy: %_file_mod_datetime_raw%

Name: File Mod DT Raw
Value: %_file_mod_datetime_raw%
Field: %DUMMY%
SortBy: %_file_mod_datetime_raw%
Numerical: yes

Sort the files by file_mod_datetime_raw.
Select all files from one day.
Run an action, which creates a tag-field having a running number per file by discarding number 1.
Action: Format value
Formatstring: $if($eql(%_counter%,1),%DUMMY%,%_counter%)

Use this tag-field to create the optional suffix as needed, e. g.

Ideally each date resp. datetime value should follow the international ISO8601 standard.

Sort the files in the folder by %_file_mod_datetime_raw% or by %_file_create_datetime_raw% to get the earliest/oldest timestamp at top of the list.
Then ... using the topmost file ... format the directory name ...
Action: Format value
Note: In the moment when the first file has been touched and the folder has been renamed, all files within this folder are moved together to the new place within the foldertree of the drive.


Thanks for pointing me in the right direction DetlevD, always helpful advice :slight_smile: .

After doing some more research I've almost completed the Action, but there is one thing that I still can't figure out.

Regarding the counter suffix code, I performed the Action on the files, but it only renamed each file in the directory (in order of timestamp) '.......-2.flac', '.......-3.mp3', etc.

Is there a way to only add the counter to files that share the same Artist on the same day?



And change it's behaviour if no Artist has been specified (also if the counter can consider the extension):


I know this sounds a little over-the-top, I'm trying to cover all bases so the Action can run regardless of what details have been added.

Mp3tag is not able to detect a group-change resp. cannot compare tag-field content between two adjacent files (in the interactive part of Mp3tag).
Such comparing would be possible only within an Export script, which analyses the given tag-fields and creates output to text file, from which in turn values can be imported into tag-fields.

See also ... unresolved ...
I wish I could always $get() a variable


OK, so this is my theory on how I could add per-artist, per-extension counters:

1. Firstly, to avoid a naming collision between the same Artist on the same day, the files would be named with the full 'ReleaseTime' tag (time is square-bracketed).

Eg: '2012.06.01[105646].mp3'

  1. The files would then be organized into seperate folders based on file/tag properies, in a structure like so:

Parent Directory>

3. The Action then would use the Export function to Export a list of each folder's filenames to a per-directory TXT file. The TXT file would contain a list like so (with the first file of each folder left blank):


3. By then using DetlevD's lookup table action the Export file (all named 'Counter.txt') would be Imported, and if the filename of the track matches the filename in the list the number to the right of the '|' delimiter would be added to a tag named 'Counter'.

4. The Action would then reformat the filenames to 'DDDD.DD.DD %artist%['-'%counter%]', and replace all whitespaces to underlines, which would look like:


5. After this the Action would relocate all the files in the child directories back into the original parent directory and run a script which would delete any folders named 'flac', 'mp3', etc.

Issues I'm having with this concept:

1. When the action is completed the following error message pops up from Mp3Tag (repeated for as many files as processed):

Import text file "Counter.txt": LOOKUP_RESULT: File [Path to directory/sub-directory]\Counter.txt cannot be accessed.

Two things aren't happening. The first is that only one 'Counter.txt' is being created (in the parent directory), even though 'One file per directory' is checked. The second is the following:

An Export file is created when I check the parent directory, so I presume that what is happening is the Action runs so fast that when it reaches the Import Text File function the 'Counter.txt' file hasn't had enough time to be created on the disk yet.

Note: If I run the Action again (after the 'Counter.txt' file has actually been created) then the Action does Import from the txt (only if no sub-directories have been created, though). So the the question is:

Is it possible to Export and Import in the one action (Exporting one file to each sub-directory created earlier in the Action, and Importing one file from each sub-directory)?

2. In the Action, after the Lookup Table functions, I reformat the names of the files to the format mentioned in point #4 of the concept section. The problem is that because of the Export TXT file not being created in time the Export list is named after the reformatted filenames, even though the Export function was invoked prior to the reformatting function.

Therefore the Lookup Table function is trying to match the pre-formatted filename with the re-formatted filenames stored in the delayed Export file, which don't match at that point in the Action.

This all seems a_bit_much when all I think I would need is a 'Reset counter per directory' parameter available as a new feature when using the %_counter% placeholder.

The workflow is cleverly devised.

How do you remove all the folders, which have been created in the meantime?
Maybe an export script is not needed, but I am unsure.
Maybe an export script can help to do the folder cleanup.

Note: Mp3tag executes an action "Export" at end of the actiongroup, regardless where the action has been placed in the series of actions.

Check the filepathname.
Does slash and backslash work the same?
If there are forbidden characters, then $validate the filepathname.
If there are spaces, then enclose the filepathname in double apostrophes.



Here is my practical proposal ...

Make sure you have some test dummy files in a test folder.
You can create these test files by running a "MakeTestFiles.cmd" file having this content ...


The SLEEP command makes sure, that the files will be created with different date time stamps.
The SLEEP command is taken from the "Microsoft Windows NT Workstation Resource Kit", but it is possible native part of Windows Vista and Win 7 too.

Fill the ARTIST tag-fields with the artist names ... here ...

Distribute the files into separate folders.
Select all files.
Use the converter "Tag - Filename"
Formatstring: 'TEMP'%_extension%''%ARTIST%''%_filename%

Select all files.
Use the "Autonumbering Wizard"
Begin at track number 1.
Only set option "Reset counter for each directory".
Execute numbering.

Collect the previously distributed files back into one folder.
Select all files.
Use the converter "Tag - Filename"
Formatstring: 'TEMP'%_extension%''%ARTIST%''%_filename%'........'%_filename%

Remove the empty folder tree, starting at folder TEMP.

Save the track number into another tag-field.
Select all files.
Execute action "Format value"
Field: POS
Formatstring: %TRACK%

Use the POS number to name the files in subsequent order.
While renaming discard the POS number 1, but use all numbers greater than 1.


Step 7 creation of the tag-field POS is not needed, because at this point in time it is also possible to read the running number per artist directly from the tag-field TRACK.

The fine art is now, to pack all of these activities into an action group. :wink:


I put together a workflow, which someone can go, but it is still not easy going, as always it is a little odyssey and rather complicated, because of the "Stilbruch" between the action area and the converter area.

Given is a set of files in a folder, which should be enumerated per Artist.

Step 3.1.
Distribute the files into subfolders per artist.
The enumeration will be done externally by an export script, which creates a CSV file, which has to be imported by the converter "Textfile -Tag" in the next step.
The CSV file will be created on the Desktop and can be removed manually after step 3.2 is completed.

Step 3.2.
Manual execution of the converter "Textfile - Tag" against the selected files, using the CSV file from the previous step.
User must set manually ...
Filename: Filepath to the CSV file
Formatstring: %POS%~~~%_path%
(... do ignore possible import error message about not parsed lines.)

Step 3.3.
Collect the files from the subfolders back into the home folder from step 3.1.
The subfolder tree will be deleted by a command file, which has been created by an export script.
The command file must be executed manually when step 3.3. has finished
(automatic execution is not possible from within action group).
The command file removes itself from the desktop after execution.

Begin Action Group Test_2012#20120605.LB.EnumerateFiles.Part1

Action #1
Actiontype 5: Format value
Field ______: STEP
Formatstring: [Step 3.1, LB.EnumerateFiles. Distribute files into folders. Create CSV file for converter "Textfile - Tag".]

Action #2
Actiontype 5: Format value
Field ______: _FILENAME
Formatstring: 'TEMP'%_extension%''%ARTIST%''%_filename%

Action #3
Actiontype 15: Export
Select script filename: Export CSV EnumerateFilesInSameFolder
Export filename ______: $getEnv('USERPROFILE')'\Desktop\Export.CSV.EnumerateFilesInSameFolder.txt'

[_] Append data [_] One file per folder

End Action Group Test_2012#20120605.LB.EnumerateFiles.Part1 (3 Actions)

Begin Action Group Test_2012#20120605.LB.EnumerateFiles.Part2

Action #1
Actiontype 5: Format value
Field ______: STEP
Formatstring: [Step 3.2, LB.EnumerateFiles. Manual execute "Converter Textfile - Tag" to import CSV values.]

End Action Group Test_2012#20120605.LB.EnumerateFiles.Part2 (1 Action)

Begin Action Group Test_2012#20120605.LB.EnumerateFiles.Part3

Action #1
Actiontype 5: Format value
Field ______: STEP
Formatstring: [Step 3.3, LB.EnumerateFiles. Collect files from subfolders into home folder. Create CMD report to remove subfolder tree.]

Action #2
Actiontype 5: Format value
Field ______: _FILENAME
Formatstring: 'TEMP'%_extension%''%ARTIST%''%_filename%'........'%_filename%

Action #3
Actiontype 15: Export
Select script filename: Export CMD RemoveTempSubFolderTree
Export filename ______: $getEnv('USERPROFILE')'\Desktop\Mp3tag.RemoveTempSubFolderTree.cmd'

[_] Append data [_] One file per folder

End Action Group Test_2012#20120605.LB.EnumerateFiles.Part3 (3 Actions)

Export_CSV_EnumerateFilesInSameFolder.mte (264 Bytes)
Export_CMD_RemoveTempSubFolderTree.mte (265 Bytes)

Additional give-aways ...
Export_Detect_Same_FolderName.mte (687 Bytes)
Export_Detect_Same_AlbumName.mte (664 Bytes)


Export_CSV_EnumerateFilesInSameFolder.mte (264 Bytes)

Export_CMD_RemoveTempSubFolderTree.mte (265 Bytes)

Export_Detect_Same_FolderName.mte (687 Bytes)

Export_Detect_Same_AlbumName.mte (664 Bytes)

What a mammoth undertaking! Thanks ever so much for your advice.

Considering the practicality of both our processes, and the fact that Mp3Tag can't easily handle such a task, I decided to change my Action to handle the problem in a simpler way.

Specifically I've taken out the automatic folder creation, Export/Import function, and the need for a CMD batch to be run for cleanup.

Basically the only thing the user is now required to do for every recording session (apart from the first) is create a new folder ('2' for the second session, etc) within the original directory.

It's a compromise, and I'm not 100% sure about it yet, but here's an outline of it as it stands:

Overview of current Action:

So originally the directory and files would look like this to begin with:

_Latest Rip>
AudioTrack 01.flac
AudioTrack 01.mp3

After the Action is run:

2012.05.31_Artist_Name [original].flac

The files of the next recording session of the day would then be manually added to the existing directory in a newly created folder named '2'.

The Action is run again to format the files. The Action recognizes that the new files are within a sub-directory named '2' and appends the '-2' to the end of the files in that sub-directory, so:

2012.05.31_Artist_Name-2 [original].flac

The Action will not rename any sub-directories named '2', '3', etc.

I also decided to allow for 'escape' sub-directories - directories that will not have their files renamed. This is useful for storing alternate versions of an edited track. Any sub-directories named 'Edit'/'Edits' will be 'escaped', even if inside another sub-directory.

Not perfect, but I think it's the most straightforward approach.

By the way, before coming to this revision of the Action, I considered first moving the directory to the Recycle Bin, doing the Export/Import dance, then moving just the files out to a new directory where I'd like it. Unfortunately this permanently deletes the files and crashes Mp3Tag :rolleyes:.

Further thoughts:

I also thought of posting a new feature request for a $counter() script function which would contain a placeholder string, or multiple placeholders, to reset the counter by. I then remembered that Mp3Tag can't compare files (although maybe it could look at the Sort by column and reset per change going down the column?).

However I do think that your GUID function should be implemented as a new feature. In your proposal there is only one function, $guid(), but from what I've read there are 4 different functions available for a GUID (random, time-based, hardware-based, hash). Whichever method is used a GUID is definitely a necessity for every podcast RSS item.

Edit: also considering using the %_md5audio% hash for the of the feed item.

Maybe a good decision.

In the meantime, beside multiple other same products available, you can use my GUID generator from there ...

A GUID is a nearly everlasting unique identifier for almost all things around in the world and the near cosmos.
I would like to have a function $guid() in Mp3tag, what should rather easy to implement, because it is a system function.


The MD5 hash is a checksum of some data (practically a most reliable nearly unique value) but not a unique identifier at all.