nonethefewer: (Default)
[personal profile] nonethefewer
Linux question, because I know there's an answer, I just don't know what it is:

Is there a way, on the command line (as in, I don't want to write a Perl/bash script, for heaven's sake), to delete a directory only if there's only one file in the directory?

Context: removing the artist folders for one-hit wonders I don't care about.

Moar context:

a) I imported a bunch of music from Dad, which included a bunch of "Hits Of The ##s"-esque albums.

b) My music files are: Music Folder/Artist/Artist - Track.mp3

I am weeding through the Hits albums, so I select just those albums in Rhythmbox.  I find I don't like Track by Artist, so I go to delete the folder.

However, there are times when I will have two whole tracks by that artist, one which I like and is not on a Hits album.  Like... Bonnie Tyler, "Total Eclipse Of The Heart", I like that.  But I don't like "It's A Heartache", which is on a 70s hits album.  Therefore, I don't want to willy-nilly delete the entire folder.

Most of the rest, though, is just one track in the folder.

So I want some command that will go "If there's just the one item in the folder, remove the folder".
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

February 2022

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728     

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 19th, 2025 10:42 am
Powered by Dreamwidth Studios