(no subject)
Sep. 29th, 2009 09:55 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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:
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".
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".