Empty folder

Hello

I would like to know if there is an automatic way to find out all the empty sub-folders via Mp3tag; but only those that have a name that do not appaer in the ARTIST tag of all the files that are stored in some of all of those sub-folders

Right now I have structure of folders like this:

D:\Musikk\Band A
D:\Musikk\Band BB
D:\Musikk\Band CCC
D:\Musikk\Band DD DD
D:\Musikk\Band Eeeeee
D:\Musikk\Band ffffffffffffffff

And I my have song by artists like:

Band A
Band BB feat. Band CCC
Band DD DD & Band A

But It could be that I no longer have a song by artists:

Band A feat. Band Eeeeee
Band ffffffffffffffff

And as such the "Band Eeeeee" and "Band ffffffffffffffff" folders should be removed

So I would need to run some kind of export code that would take every sub-folder [name of artist] from D:\Musikk\ and compare it to all the values of ARTIST tag from all of the files found in D:\Musikk*, case by case; and write down a list of folders that do not have their counterpart in tags

Is it doable?

Mp3tag get the knowledge of a folder name and other file or folder related system values, ...
only when there exist a media file, which can be detected by Mp3tag, ...
and which is displayed in the Mp3tag list view.

If you want to remove empty folders from the disk, then you need a separate tool.
There are some proposals burried in the forum.

DD.20150330.2158.CEST

If you need something to script with ...
here is a proposal for a Mp3tag export script, ...
which creates a batch cmd script, ...

1: $filename($getEnv('USERPROFILE')'\Desktop\Mp3tag.RemoveEmptyFolder.cmd',ANSI)$puts(

2: )'@ECHO OFF'
3: $loop(%_folderpath%%DISCNUMBER%,1)
4: 'ECHO.Removing ... "'%_folderpath%%DISCNUMBER%'"'
5: 'RD "'%_folderpath%%DISCNUMBER%'"'
6: $loopend()
7: 'PAUSE'
8: 'DEL "%~0" 1>NUL 2>NUL & EXIT'

Note: Probably the locations in the script, ...
where the tag-field %DISCNUMBER% has been referred, ...
there is the place to code something, which can check for other tag-fields, ...
and which evaluates the decision for removing a folder.
Note: The DOS command RD only removes a folder, when the folder does not contain any file.

Maybe this hta script can help to remove empty folders ...
pcwEmptyFolder.zip (2.52 KB)
DD.20150330.2240.CEST

pcwEmptyFolder.zip (2.52 KB)

That is what I thought; and I know that's it is impossible to achieve what I'm asking of using the filter [because Mp3tag can't show "no file" in the list]

But I thought, maybe Mp3tag could chew all the files and spit out via export a list of folders [not files]

I do not want to remove empty folders; well, maybe only few of them [and repeat that in future]

Right now an empty folder "Artis A" gives me an info, that I have at least one song by "Artist A"; on which that artist is only featured, or is the remixer of- but is not the main album [first] artist. And this is only for statistical purposes: the number of folders equals the number of individual artists from all the songs

And the problem is, that in time I will forget to delete folders of artist now longer present in ARTIST tag in at least one file. Because a deletion of folder will only be required when the last song with a given artist is deleted- and checking that every single time a deletion occurs will be a drag

So I have a choice- find a way to automatically evaluate empty folders or find a way the count the number of artist from all the files; or wash down the drain this statistical issue

To me this looks like a purely academical discussion.
Honest: how often do you scan through your library and the filesystem in parallel?
As empty folders are not marked as empty by the file system so that you do not get any hint while browsing through the folder list, you have to open each one individually only to find it is empty or not.
And even if it is empty then this would not mean that the artist has disappeared but it could just as well be that before, there was a typo in the name and the emptiness of the folder is more than justigied.

And then you really want to enter a filter to look for the name of the artist in the program that shows the tags?
What a cumbersome process! That might work for a few dozens but that's it.
If you have that artist name in the tags, you will find it with the program that reads the tags.
MP3tag, BTW, would not even display that folder. So at least from within MP3tag this would not be of any help.
Here is a link to a really tiny program to delete empty folders:
http://www.pcwelt.de/downloads/pcwEmptyFolder-1211678.html

I suspect you need some 'null' or 'zero' object to handle the case of 'empty folder'.
So ... create a dummy mp3 file, name it as you will, give it tag-fields as you will, ...
and you will stay informed, even from the view of Mp3tag.
There are several ways to create dummy mp3 files, here are some simple proposals ...

Type on the DOS command line ...
ECHO.xxx>dummy.mp3
... or ...
echo.xxx>"%USERPROFILE%\Desktop\dummy.mp3"

... or ...
Execute this Mp3tag export script ...
$filename($getEnv('USERPROFILE')'\Desktop\dummy.mp3',ANSI)'xxx'

... or ...
Use a text editor and save some letters into a file, ...
save it as "dummy.mp3" or what you want.

Load the dummy mp3 into Mp3tag.

DD.20150331.2129.CEST

Never

All of this comes to one thing thing: statistics

For example: I now how many "score" track I had at different points in time throughout the years- and now I can see, how my passion for cinematic music increased from 33% to 55% in my collection. And that has nothing to do with the listening process

That is exactly the problem

Until recently, my every [also featured] artist had its own folder, with copies of tracks in it. But now [Playlist making] I'm left with some empty folders. And right now it is accurate- but in time errors will show up [folders that should be removed because of absence of a given artist in form of tracks]

That is way I need an automatic process; that would spit me a short list of folders [errors] to be removed. So that I can retain good empty folders; so that in turn I can just enter to main folder and see how many artist I have in my collection [just as I can tell how many tracks I have]

The only way this workaround could work would be, if I would store a marker in form of a dummy file in every folder, not only the empty ones. This is of course doable but I an see one big problem: I would have 3000+ unwanted files on my list, probably all with the one same name. And something like 9 out of 10 times after loading my files to Mp3tag I would start by removing them from the list; so I can imagine that after doing that for the 2066th time I would have had it with this motherfracking files on this motherfracking list

In the database world, I think that reports are generated for a snapshot to get the statistics.
I would recommend the export features of mp3tag to generate such snapshots and use other programs than the filesystem browser to compare these two snapshots.
If it is supposed to become automatic, then using empty folders with dubious spellings of names is the worst foundation for such statistics.
Instead, use the sorting and filtering functions in Mp3tag and the exports and go on from there. The current approach is bound to head for a dead end. Even now you see a lot of problems and drawbacks.

This is a fallacy.
You want a marker for emptiness, now you got one.
Only those folders where the marker dummy file resides, these are the empty folders in question.
It is rather easy to set up a filter to show only those folders, ...
respectively to not show those folders in the Mp3tag listview.
And ... the best effect is ...
due to the helper dummy file you have full access to the folder related informations, ...
which Mp3tag is able to retrieve.

I do not expect any conflict between 'busy' folders, which contain files with full sized names and tag-values.
On the other side there are the 'dead folders', where the 'ghost' files reside, simply named as "_.mp3" as a reminder, ...
maybe having only one tag-field with 1 byte data, ...
to allow them to be sorted out or filtered away to invisible, ...
when other work is needed on the main section of media files.

And there is also the option to rename the file extension of the 'ghost' files to a special name, ...
for example ... "ghostfile.zerow".
This can be defined in the Mp3tag options, ...
whether this filetype should be displayed or not.

DD.20150331.2316.CEST

In theory, would it be possible to create such and export code, that would:
1] look at an ARTIST tag of every file
2] write down to a list everything that is put there
3] remove from list every repeated search of strings
4] count individual strings
?

My ARTIST tags are in format
Band A
Band A feat. Band B
Band A feat. Band B & Band C
Band D feat. Band E, FFF, GGG & Band HHH

So at the end I would have to something like:

0001 Band A
0002 Band B
0003 Band C
0004 Band D
0005 Band E
0006 Band FFF
0007 Band GGG
0008 Band HHH

[but no necessarily in alphabetical order]

Or is it impossible, in single take / in Mp3tag [and what is you were trying to explain to me]?

This gives some ways to deal with the issue

Well, right now the big problem is the evaluation [by hand] of those empty folders [aside from making a permanent marking o some sort]. Because some are empty because they should have been removed a long time ago or are empty on purpose only recently but also on purpose [meaning that I no longer have any song with that artist, beacasue I deleted it a few weeks ago]

First way to do it is to copy name of the folder to the filter and see if anything shows up [if yes, then it stays; if not, the folder / artist is to be deleted]

The alternative method would be to first filter and then look for folders. In order to do that I would have to:
1] make a copy of all files
2] search for all "feat." in ARTIST tag
3] replace everything before "feat." with nothing
4] replace every "feat." with nothing
And I do not know how to do the step number 3

Example ...

From: 'replace everything before "feat." with nothing' To: '"feat." with nothing' Formatstring: '"'$cutLeft('replace everything before "feat." with nothing', $strstr('replace everything before "feat." with nothing','"feat'))

... or in one go ...

$ifgreater($strstr(%ARTIST%,' feat. '),0, $cutLeft(%ARTIST%,$add(6,$strstr(%ARTIST%,' feat. '))),%ARTIST%)

DD.20150408.1615.CEST

You may achieve the wanted result by a report script, ...

  • where you can 'sum up' ... all the %ARTIST% strings into one variable by ...
    $puts(list_all,$get(list_all)', '%ARTIST%)

... after end of the loop ...

  • replace all unwanted text with separator strings ...
    $puts(list_all,$replace($get(list_all),' feat. ',', ',' & ',', '))

  • remove all duplicates ...
    $puts(list_deduped,$regexp($regexp($regexp($get(list_all),'(?:(?<=,)|(?<=\A))\s?([^,]),(?=.?(?<=,)\s?\1(?=,|\Z))',,1),'(,\s+)',','),'^[ ,]+|[, ]+$',))

... then use the result for report output ...
$get(list_deduped)

DD.20150408.1743.CEST

Once again, I want to do some advanced stuff, but my lack of basic knowledge obviously comes in the way

I simply can't get past the first step

If i use for export

then as a result I get an empty file

And if I use code

then it takes a very long time to generate me a file full of empty lines

1: $filename($getEnv('USERPROFILE')'\Desktop\Test.txt',UTF-8)

2: $loop(%_folderpath%)$puts(list_all,$get(list_all)', '%ARTIST%)$loopend()
3: $puts(list_all,$replace($get(list_all),' feat. ',', ',' & ',', '))
4: $puts(list_deduped,$regexp($regexp($regexp($get(list_all),'(?:(?<=,)|(?<=\A))\s?([^,]),(?=.?(?<=,)\s?\1(?=,|\Z))',,1),'(,\s+)',','),'^[ ,]+|[, ]+$',))
5: 'List of all artists, separated by comma ...'
6: $get(list_deduped)

1: $filename($getEnv('USERPROFILE')'\Desktop\Test.txt',UTF-8)

2: $loop(%_folderpath%)$puts(list_all,$get(list_all)', '%ARTIST%)$loopend()
3: $puts(list_all,$replace($get(list_all),' feat. ',', ',' & ',', '))
4: $puts(list_deduped,$regexp($regexp($regexp($get(list_all),'(?:(?<=,)|(?<=\A))\s?([^,]),(?=.?(?<=,)\s?\1(?=,|\Z))',,1),'(,\s+)',$char(13)$char(10)),'^[ ,]+|[, ]+$',))
5: 'List of all artists, separated by CRLF ...'
6: $get(list_deduped)

DD.20150423.1757.CEST

Thank you very much, that will save me a whole bunch of time

I use now a code like that for exporting:

$filename(txt,utf-16)

$loop(%_folderpath%)$puts(list_all,$get(list_all)', '%ARTIST%)$loopend()

$puts(list_all,$replace($get(list_all)
,' cond. ',', '
,' feat. ',', '
,' interp. ',', '
,' vs. ',', '
,' & ',', '
,' + ',', '
))

$puts(list_deduped,$regexp($regexp($regexp($get(list_all),'(?:(?<=,)|(?<=\A))\s?([^,]*),(?=.*?(?<=,)\s?\1(?

=,|\Z))',,1),'(,\s+)',','),'^[ ,]+|[, ]+$',))

'List of all artists, separated by comma ...'

$get(list_deduped)

But to tweak it even further:

1] Now I get a list like

Artist Z,Artist A,Artist 999

instead of

Artist Z, Artist A, Artist 999

which I presume is the side effect of making the doubled artists disappear

While making a compact list [without repeated artist] is the priority, the lack of commas is not. So, it's not really an issue

2] How to break a line after each coma? So that the list would be vertical? [It's not really an issue]

3] How to automatically count artists from the list and put a number next to each? [It's not really an issue]

4] How to, in along the export process, get rid of variations? Right now I have in my files ARTIST tags like

Artist A *2
Artist A feat. Artist B *3
Artist B *9

which are spitted out by this export code like

Artist A *2,Artist A,Artist B *3,Artist B *9

but should be spitted out as only

Artist A,Artist B

[This is a big issue]

5] How to automatically count the artists? I could open the exported file in a text editor and replace all the comas with some sign and look at the end information of a process [giving me the number of comas, which would be the same as a number of artist minus 1]. But that are manual additional steps. So is there a way to do it in export list?

[This is an smaller issue]

6] How to rearrange list alphabetically? If it would be in order I could easily look [manually] for some possible errors

zerow, if you compare the code of both export script examples, ...
then you can see, within one of the nested regexp functions, ...

  • there is one replacement defined as ','
  • there is one replacement defined as $char(13)$char(10)
    This is the place, where you can make the change to set a different separator string of your wish.

DD.20150425.1704.CEST

I'm sorry, I should have done this comparison on my own; that was very lame of me

Now I use code like this

$filename(txt,utf-16)

$loop(%_folderpath%)$puts(list_all,$get(list_all)', '%ARTIST%)$loopend()

$puts(list_all,$replace($get(list_all)
,' cond. ',', '
,' feat. ',', '
,' interp. ',', '
,' voc. ',', '
,' vs. ',', '
,' & ',', '
,' + ',', '
,' *2',' '
,' *3',' '
,' *4',' '
,' *5',' '
,' *6',' '
,' *7',' '
,' *8',' '
,' *9',' '
,' *10',' '
,' *11',' '
,' *12',' '
,' *13',' '
,' *14',' '
,' *15',' '
))

$puts(list_deduped,$regexp($regexp($regexp($get(list_all),'(?:(?<=,)|(?<=\A))\s?([^,]*),(?=.*?(?<=,)\s?\1(?=,|\Z))',,1),'(,\s+)',$char(13)$char(10)),'^[ ,]+|[, ]+$',))

'List of all artists, separated by CRLF ...'

$get(list_deduped)

And so with it, a set like that

Artist Z
Artist A + Artist B
Artist A feat. Artist B
Artist A feat. Artist B *2
Artist A feat. Artist B *2 + Artist A feat. Artist C + Artist B*3
Artist C feat. Artist D
Artist D
Artist D *13

is exported out a result like this

Artist Z
Artist B
Artist A
Artist A
Artist C
Artist B

Artist C
Artist D
Artist D
Artist D

and it should be spitted out at least as

Artist Z
Artist B
Artist A
Artist C

Artist D

but it would be better shown as

Artist A
Artist B
Artist C
Artist D
Artist Z

and best given as

0001 Artist A
0002 Artist B
0003 Artist C
0004 Artist D
0005 Artist Z

So the main problem is ruling out repetitions, but not only in one file, but in comparison to other files. And because Mp3tag can't compare different files [their tag fields], as it was explained to me in earlier in other topics, it is the [pre]generated list that should be run over in search for repeated positions [artists] and cleaned of them

Is it doable?

Have look at the help for exports:
http://help.mp3tag.de/options_export.html

"...If you want to limit the loop output to a certain number of entries, simply use $loop(%fieldname%,num). This is useful to eliminate duplicate records (num=1). "

So if you add a $loop(%artist%,1) .... $loopend()
around the whole putting and getting, you should get a sorted list with each artist only once.

And for the comparison of similar files I can recommend "similarity" (a web search should find it) which lets you look for similar files in respect to contents and tags.

Hmmm

I've tried putting the

$loop(%artist%,1)

somewhere at the beginning [in different places ], and the

$loopend()

somewhere at the [or near] end

But the best result I got was the one with only

Artist Z

I'm not comparing files per se. My search is limited to ARTIST tag; which can have one and the same artists in many variations [but always spelled the same way] and in many files

If you want to sort the ARTIST somehow, it might be worthwhile not to sort by filename but by artist. Or you would have to sort that part of your export script where there is more than one artist in the list.

In respect to similarity: I would say: give it a try. This program finds similar files with adjustable fuzziness in respect to contents and/or tags.
Playing around with these settings might generate just lists you try to get.

As user 'ohrenkino' already said, it might be useful to use sorted ARTIST values instead of sorted folderpath values, so ... replace ...
$loop(%_folderpath%)
... with ...
$loop(%ARTIST%)
... and try again.

Note:
Mp3tag is not a "Eier legende Wollmilchsau" (german) or "jack of all trades" (english).
Sometimes you have to use other tools beside Mp3tag to reach a specific goal.
A good text editor like Notepad++ can help.

DD.20150428.0827.CEST