Page 2 of 2

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Mon Nov 11, 2019 7:23 am
by KeithLatham
waxcylinder wrote:
Sun Nov 10, 2019 10:37 am
KeithLatham wrote:
Sun Nov 10, 2019 2:27 am
Further to my earlier reply.
Alternatively, you could place sides 1 and 2 in the same track and Export Multiple both sides, though that would not allow you to list "side 1" / "side 2" in the metadata.
Yes, that is a viable solution. I could edit the metadata 'on the way through' to change the side number, just as I currently change the track numbers for the second side. This would be fairly straight forward.
Personally I preferred to edit my metadata in iTunes (and separately on my X30 "jukebox") once I had transferred the files there - the metadata editor in iTunes worked much better for me than trying to manage it in Audacity.

WC
ITunes is not an option. Even if we were talking about the Apple version in this forum :roll:

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Mon Nov 11, 2019 7:37 am
by KeithLatham
steve wrote:
Sun Nov 10, 2019 11:26 am
I don't understand why you say that the output is "incorrect". I'm unclear about your provide "Reproduction steps".
I mean I expect that the number appended to the beginning of the filenames produced should be equal to the track number recorded in the metadata.
What does "Edit Metadata as appropriate" mean? What are you entering for the metadata?
It means I'm filling in the fields on the Metadata tag sheet - Artist, Title, Genre, Year, etc.
Where are you entering "include a Tag for 'LP Side' = 1" ?
I have added several 'custom tags' using the Audacity editor for that purpose. One such tag I added is 'LP Side' specifically so I could sort the tracks in MP3Tag before renumbering them in order to rename the files. The 'LP Side' is not a necessary condition for this problem.

I suspect the problem could be shown by just changing the track number to something outrageous when exporting ANY file. I haven't tried this, but if you set the track number to, say, 47, and export that it will still build a filename that starts '01_' instead of '47_'.

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Mon Nov 11, 2019 9:42 am
by steve
KeithLatham wrote:
Mon Nov 11, 2019 7:37 am
I have added several 'custom tags' using the Audacity editor for that purpose.
What do you expect to happen with those custom tags?
What is actually happening with those custom tags?
KeithLatham wrote:
Mon Nov 11, 2019 7:37 am
It means I'm filling in the fields on the Metadata tag sheet - Artist, Title, Genre, Year, etc.
It's your use of words like "etc" that make it impossible to understand what you are trying to say. We don't know what you mean by "etc" unless you tell us. You have told us that "etc" includes some "custom tags", but not exactly what tags you are supplying.
KeithLatham wrote:
Mon Nov 11, 2019 7:19 am
Then when I do side 2, I specify in the metadata the track number to use for each track, (4, 5, 6). I EXPECT the output files to be named 04_ 05_ 06_.
Where does the documentation suggest that metadata is passed through to the file name? (metadata plays no part in naming the exported files).

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Wed Nov 13, 2019 2:34 am
by KeithLatham
What do you expect to happen with those custom tags?
I expect Audacity to write them to the metadata on the file.
What is actually happening with those custom tags?
Audacity is actually writing them to the metadata on the file.

I don't understand why this is causing you confusion about the issue. The custom tags are not involved in the issue.

Track number is NOT a 'custom' metadata field, it is a standard field present in all metadata output formats.
Track title is NOT a 'custom' metadata field, it is a standard field present in all metadata output formats.
It's your use of words like "etc" that make it impossible to understand what you are trying to say. We don't know what you mean by "etc" unless you tell us.
OK. I'll apologize for that.

"etc." means "and so forth" and is used to denote that there are other items that would just be tedious to list and not add any value to the discussion.
You have told us that "etc" includes some "custom tags", but not exactly what tags you are supplying.
You are focusing on irrelevant detail instead of addressing the issue at hand. Audacity is handling the custom tags exactly as it should be. The custom tags I added have no bearing on that issue. You do not need to use any custom tags to replicate the problem.

The problem is NOT IN THE METADATA. The problem is that the output file NAME, that is the name the operating system sees, is not being built properly. The file should be named by combining the track number from the metadata with the track title from the metadata. This has nothing to do with custom tags in the metadata - it has to do with using a loop counter to name the file instead of the actual track number.
Where does the documentation suggest that metadata is passed through to the file name? (metadata plays no part in naming the exported files).
Well, the track name is part of the metadata, it comes from the labels we put into the project, so yes, in that way, the file name does come from the metadata because the label is a piece of metadata.

But I get your point, you are saying that the routine that cuts the file gets its name from the labels before it constructs the metadata object, and therefore does not have access to the metadata.

My point is that this is a design decision which results in "incorrect output" because the expectation of most people who number file names is that the filenames match the track number.

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Wed Nov 13, 2019 11:23 am
by steve
KeithLatham wrote:
Wed Nov 13, 2019 2:34 am
The file should be named by combining the track number from the metadata with the track title from the metadata.
OK I see. That is the way that you would have designed Audacity, but it is not the way that the feature was designed. This is not a "bug", it is a disagreement about how Export Multiple should handle metadata and file names.

What Audacity actually does regarding the file name when performing "Export Multiple":
If exporting based on "tracks", then the name of the track is used as the file name, otherwise export is based on "labels" and then the label is used as the file name.
Because you can't have two files in the same directory with the same file name, attempting to write a second file with the same name as an existing file would overwrite the existing file. That would defeat the point of "Export Multiple", so to avoid overwriting existing files, Audacity will append a number to the file name in this case so that each exported file has a unique name.

Example:
If you have 3 tracks, named "AAA", "BBB", and "AAA", and no labels.
Export multiple is "based on tracks".
The Exported files will be named "AAA", "BBB" and "AAA-2".
The "-2" has been appended to the file name of the second file that would otherwise have overwritten the first "AAA" file.

Export multiple is always based on "tracks" OR "labels" (not both), so the file names come form either the track names, OR the label name.

If you name the tracks as "AAA-1", "AAA-3", and "AAA-2", and export multiple WAV files based on tracks, then the file names will be (respectively): AAA-1.wav, AAA-3.wav, and AAA-2.wav, but because the metadata "track number" tag just increments from "1", the metadata track numbers will still be 1, 2 and 3 respectively, because that was the order of the tracks in the project.

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Sat Nov 16, 2019 4:36 am
by KeithLatham
If you name the tracks as "AAA-1", "AAA-3", and "AAA-2", and export multiple WAV files based on tracks, then the file names will be (respectively): AAA-1.wav, AAA-3.wav, and AAA-2.wav, but because the metadata "track number" tag just increments from "1", the metadata track numbers will still be 1, 2 and 3 respectively, because that was the order of the tracks in the project.
Yes, I this is a good strategy to avoid naming collisions - i.e. putting a unique number into the file name.

This still doesn't really address the issue though. Audacity must be checking for unique label/track names BEFORE it starts writing the file because, according to your example, it only appends a number if it detects a collision. But, if we tell it specifically to ALWAYS put a number into the file name by checking the 'Numbering before label name/track name" option, Audacity doesn't need to do any checking what-so-ever because the resulting filename is guaranteed to be unique (unless... see below).

The question then becomes, where do we get that sequence number from? Clearly, Audacity is getting it from a loop counter; my argument is that it should come from the output track index as stored in the metadata.

Here is my reasoning:

First the scenario that I am trying to 'clean up'. We record an LP, side one is saved as Project A; side two is Project B. The LP tracks are labeled. For the sake of the discussion lets suppose that the first LP track on BOTH sides is labeled 'AAA' and there are 5 track/labels on each side.


1) We export multiple Project A into FolderZ with numbering ON.
=> So FolderZ now contains 5 files, the first one has the name 1_AAA.wav.

2) Now we export multiple Project B into the same FolderZ with numbering ON.
=> and we have a name collision error when the Side 2 label 1_AAA.wav file is attempted.

Notice that the user has NO WAY to avoid this collision name because the sequence number is generated from an internal loop counter of some sort.

On the other hand, and the point I'm trying to make is, the user DOES have control over the metadata track index, because Audacity gives the user the chance to modify the metadata before it writes it to the file, and it does this for all track/label metadata sets before it begins to write any of the files.

If the metadata track index was used instead of an internal sequence number the scenario would shake out like this:

3) We export multiple Project A into FolderZ with numbering ON.
=> Just as before FolderZ now contains 5 files, the first one has the name 1_AAA.wav.
=> This is identical to item (1) above

4) Now we export multiple Project B into the same FolderZ with numbering ON
=> If the user did nothing, we would get the same name collision as before, because the metadata track number starts at 1 each time.
=> This is identical to item (2) above since the user did nothing to chance the default metadata track index.

However, we CAN change that metadata track number before Audacity begins to write the files. So instead:

5) Now we export multiple Project B into the same FolderZ with numbering ON.
=> Audacity presents us with the Metadata edit form, once for each track/label it is going to export
=> As each edit form is presented, we change the track number to '6', '7', '8', '9', '10, each in turn
=> Audacity uses the track number for the file name and Side 2 label 6_AAA.wav is written and there is no name collision.

This is the specific reason that I refer to the current situation as 'incorrect output' even though I fully realize it is the designed result. The design, as coded, is GUARANTEED to produce a name collision in the scenario as presented, even though the design is specifically supposed to avoid that problem - as described by you in your reply.

Furthermore, as an end user, I expect to have control over the output file name as much as practical - and this suggestion does just that.

Finally, the implementation should be quite simple, I think, (though of course I am not looking at your code), I am not suggesting that you 'turn off' the collision detector code at all. Rather I suggest that before you check for file name collisions, however you do it, you add another step if the user has asked for file numbering, simply prepend the metadata track index to the file name instead of the loop counter.

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Sat Nov 16, 2019 11:14 am
by steve
KeithLatham wrote:
Sat Nov 16, 2019 4:36 am
my argument is that it should come from the output track index as stored in the metadata.
Audacity is "open source", which means that you are free to modify the source code as you wish. If you create a new feature, you are welcome to submit a "pull request" and your new feature will be considered for inclusion in the next Audacity release.

Re: Export Multiple: incorrect output - file names not numbered correctly

Posted: Sat Nov 16, 2019 11:25 am
by steve
KeithLatham wrote:
Sat Nov 16, 2019 4:36 am
Notice that the user has NO WAY to avoid this collision name
The example workflow in the manual avoids the name collision (https://manual.audacityteam.org/man/sam ... ation.html) by recording both sides into one track, and then export multiple with the entire track.

Another way to avoid that naming collision would be to create two folders, one called "Side1" and the other called "Side2".

Another way to avoid that naming collision is to ensure that you use unique label names.