Reorganize Music collection with MP3TAG, GAWK and CMD files : CMD script crashes due to UTF-8

Hello all !
I want to reorganize ALL MY MP3 files , split on different hard drives , USB-sticks ( different file systems) to my common NAS drive.

Therefore my planned workflow was :

  1. Run Mp3tag and export all the relevant data ( Tags like title, artist, filename, path,... ) into a CSV file.
  2. Run a GAWK script to convert the relevant columns of this CSV file and create a WINDOWS BAT/CMD file COPYM.BAT, which consists only of a lot of XCOPY commands.
    The lines look like this one :

xcopy /C /Y /F "C:\Users\norbe\iCloudDrive\Exchange\Cafe Anatolia \11-Şimdi Uzaklardasın.mp3" "c:\music\Pop\Ceyhun Çelik\Cafe Anatolia \11-Şimdi Uzaklardasın.mp3*"
xcopy /C /Y /F "C:\Users\norbe\Music\iTunes\iTunes Media\Music\Hélène Grimaud\Rachmaninov_ Piano Concerto No. 2, Etude\01 Concerto for Piano and Orchestra.m4a" "c:\music\Klassik\Rachmaninov- Piano Concerto No. 2- Etudes & Preludes\01-Concerto for Piano and Orchestra No. 2 In C Minor, Op. 18: I. Moderato.m4a*"

There were some problems and challenges, I could fix ( e.g.

  • the trailing '*' character at the end of the dest. filename,
  • the Suppression of the BOM character in the created CSV-file ...

Everything , works , if the xcopy filenames only contain standard 7-bit ASCII characters.
But I have many audio files with special ( international ) characters ( see the examples above : Şimdi, Hélène, ...) , so my idea was to use UTF-8 coding for the COPYM.BAT file.

But here the WINDOWS problems start - a WINDOWS command shell normally is configured/started with a country specific copepage, e.g. Codepage 850 (Europe).
In this codepage the xcopy fails : many filenames are not readable ( file not found, directory not found,.... ).
So my idea was to change the copepage to UTF-8 with :
C:> chcp 65001
( change the codepage to UFT-8 characters )

Here the files are found, but the COPYM.bat files crashes after some lines with very mystic messages, in a way, that the command parser seems to get confused with the different length of the 2 or 3-byte UTF-8 characters.

Any ideas how to get it run in WINDOWS ?
My next try will be to modify the COPYM.bat to and to run it under LINUX with cp Syntax, but I am not very experienced with LINUX and SMB filesystem mapping etc.
So my preferred solution would be under WINDOWS.....

Thanks for any good ideas and help ....

Quite honestly:
as the Converter>Tag-Filename and Converter>Tag-Tag allow to modify filenames and folder names so that these properties are renamed, I would think that the detour with GAWk and CMD are not really necessary...
And as MP3tag then takes care of the filenames, you should not run into too many problems.

Thank YOu,
this was also my first idea, seems suitable for my "project", but the mp3Tag Converter has some limitations, which can be easily handled by GAWK :

  • SKip files with Genre = "" ( all ASF files, videos, ...)
  • map similar Tags ( Classic , Classical, Klassik, ..) to one Genre ( Klassik )
  • modify some Tags ( remove trailing blanks, ..)
  • replace empty Tags ( artist, title,..) with my own string ( ""UNKNOWN-ARTIST") for post-processing

May be, this is all all possible with MP3TAG, but how to keep overwiew over the progress, if I do it in chunks ? Splitting it is really useful, due to approx. 6 different source devices/drives and approx. 30.000 files in total. WOuld be great, if mp3tag would offer such "conversion" script.

Use a filter

Use $replace(%genre%,Classical,Klassik,Classic,Klassik) instead of the simple %grenre%

Use $trim(%artist% instead of the simple %artist% - this would be a good idea to do that generally not only for the filename but also for the tag fields as well. This also would have the benefit that you would not have to create a more compliated code with additional processing functions.

Use $if2(%artist%,Unknown Artist)

As I said ... most of it is possible with MP3tag.

Coming back to

There is a setting in Tools>Options>Export whether to write BOM or not.

Thank You again.

I tried some filtering, with success ( e.g. %Genre% HAS Classi ) - works fine. Also modyfying the result set ( manually enter : Klassik and CTRL-S for saving ) worked.
Also I find many detailed descriptions and help for details ( functions, regexp ...).
But stiil unclear, what MP3TAG is ?

  • Is it an interactive tool ( select directory, do something (with or w/o filter, save ) ?
  • is it a scripting / programming tool ?
  • Where can I write scripts ? Where shall I store ? How to run them ?
    Is a script the same as Action ( in German Aktion/Aktionsgruppe? ) I only find descriptions/help for the details , but not for the workflow principle.



I think this depends an awful lot on the particular task.
For one-off tasks (like organizing ones collection into folders) it is easiest to use the interactive part.
For routine jobs like getting consistent data e.g. without leading or trailing blanks, it may be easiest to set up an action group that $trim()s all the fields where such appendices might occur. An action group is created in the menu Actions. It then contains 1 to n actions. This action group gets a user-defined name so that you can set a name that means something to you.
The help has a section about First steps. Perhaps that outlines a possible workflow

Thank You.
Still the best way is to get some suggestions like Yours, then try ( and error, or success) . The most things work like intended, but still a lot of work to tune many thousands of songs ...
Topic is solved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.