# Conditional delete

**URL:** <https://community.mp3tag.de/t/conditional-delete/42345>\
**Category:** Support\
**Created:** [July 15, 2018, 5:48am UTC](https://community.mp3tag.de/t/conditional-delete/42345 "2018-07-15T05:48:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [July 15, 2018, 5:48am UTC](https://community.mp3tag.de/t/conditional-delete/42345/1 "2018-07-15T05:48:43Z")

</div>

Hello there, I have noticed a number of singles albums in my collection and I have decided I don't want them.

I would imagine it is possible to run an action to deal with this?

I need to check if total number of tracks is equal or less than three and if so, delete \_DIRECTORY. Even if the program cannot count total number of tracks, surely it could check for the highest track number within each folder to produce the same effect?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 15, 2018, 9:33am UTC](https://community.mp3tag.de/t/conditional-delete/42345/2 "2018-07-15T09:33:06Z")

</div>

> [@sheepdisease](#):
>
> surely it could check for the highest track number within each folder to produce the same effect

No it can't.  
THis would mean that the property folder of one file would have to be compared with another file's property.  
And, as you know, Mp3tag does not compare data between files.

You could create an export that sorts by folder, counts the tracks in that folder and then outputs some kind of batch job for the command shell to delete the files.

Or you could renumber all the files and include the total number in the track number and then delete manually all the files that have a trailing 3 (or less).

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [July 15, 2018, 10:41am UTC](https://community.mp3tag.de/t/conditional-delete/42345/3 "2018-07-15T10:41:53Z")

</div>

@sheepdisease This will not recognize the second disc (of a two or more disc album) with only a few tracks.

If you don't have a tag inside your files like "[releasetype](https://musicbrainz.org/doc/Release_Group/Type)" you can't be sure it is an EP, a Single or a 1-hour-MixTape or something else.  
IMHO "total number of tracks is equal or less than three" is not accurate enough to delete files.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [July 15, 2018, 12:05pm UTC](https://community.mp3tag.de/t/conditional-delete/42345/4 "2018-07-15T12:05:59Z")

</div>

Between your responses you have come up with possible ways of dealing with this task. If it were necessary to include the total number in the track number then so be it, this could then be undone once the job was complete to revert back to %track% %title% afterwards.

For the music I have it is not possible for there to be multi-discs with anything less than 5 tracks so I really am not worried about that, although I am open to input on this concerning practical code implementation. I am making sure that 'part of set' has the correct data so this could be used in checking.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [July 15, 2018, 4:17pm UTC](https://community.mp3tag.de/t/conditional-delete/42345/5 "2018-07-15T16:17:45Z")

</div>

Still hoping this can be implemented somehow, I have a number of folders to test it on.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [July 15, 2018, 5:28pm UTC](https://community.mp3tag.de/t/conditional-delete/42345/6 "2018-07-15T17:28:07Z")

</div>

I think there are already a number of ideas in this post:

> [@Conditional delete](https://community.mp3tag.de/t/conditional-delete/42345/2):
>
> No it can't. THis would mean that the property folder of one file would have to be compared with another file's property. And, as you know, Mp3tag does not compare data between files. You could create an export that sorts by folder, counts the tracks in that folder and then outputs some kind of batch job for the command shell to delete the files. Or you could renumber all the files and include the total number in the track number and then delete manually all the files that have a trailing 3…

I don't know if you have realised: there is no action that deletes files.  
So you would have to treat the files yourself probably with a filter.  
I do not know, though, what this means:

> [@sheepdisease](#):
>
> to revert back to %track% %title% afterwards

Are we talking about filenames?  
I thought, you would sort by directory, use the function Extras\>Track numbering wizard, and set more or less all options to "on",  
The you filter for  
`%track% MATCHES "/[1|2|3]$"`  
You can now either select these files and press Ctrl-Del to delete them  
or you use an action of the type "Format value" for \_DIRECTORY with a fixed string as format string, e.g.  
Format string: d:\obsolete  
This moves all folders to just this single one and you only have to delete that folder.  
You can follow this line now or wait until the MP3tag concept gets modified and an action to delete files and folders is implemented.

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [February 9, 2026, 12:27pm UTC](https://community.mp3tag.de/t/conditional-delete/42345/7 "2026-02-09T12:27:32Z")

</div>


