Listen and sort your music, with prompt for deleting (minimal alternative version)

for i in *; do mplayer "$i" && rm -i "$i"; done
The glob pattern * expands to all files, no need for the 'ls' command. The quotes around "$i" make sure filenames with spaces in them are handled correctly. mplayer determines if it is a media file and plays it, or gives errors and the loop asks if this file has to be removed.
Sample Output
> for i in *; do mplayer "$i" && rm -i "$i"; done
MPlayer SVN-r35933-snapshot-4.7.2 (C) 2000-2013 MPlayer Team

Playing Eels - A Daisy Through Concrete.mp3.
libavformat version 54.63.104 (internal)
Audio only file format detected.
Clip info:
 Title: A Daisy Through Concrete
 Artist: Eels
 Track: 1
 Genre: Unknown
Load subtitles in ./
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 44100 Hz, 2 ch, s16le, 160.0 kbit/11.34% (ratio: 20000->176400)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:   7.8 (07.8) of 146.0 (02:26.0)  0.9% 

Exiting... (Quit)
rm: remove regular file ?Eels - A Daisy Through Concrete.mp3?? 

MPlayer SVN-r35933-snapshot-4.7.2 (C) 2000-2013 MPlayer Team

Playing test.txt.
libavformat version 54.63.104 (internal)

Exiting... (End of file)
rm: remove regular empty file ?test.txt?? 

By: warkruid
2013-12-26 17:13:23

1 Alternatives + Submit Alt

What Others Think

These are indeed the fascinating things about music. Not only that, also provides great ringtones that you can consult and use them for free.
Calantha · 6 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: