LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-06-2010, 05:34 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Making mplayer skip some files.


GNU/Linux kernel 2.6, Slackware 12.0
MPlayer 1.0rc2-4.1.2
GNU Bash 3.1.17

Hi:
I've got a set of MP3 files on dir .../foo/ and I want mplayer to play them sequencely but skipping some of them. If I run 'mplayer *' this will do but ofcourse won't skip any files. I think a shell script could be written to do that. It would be something like this (using some pseudocode):

#!/bin/bash
#After an example from Intro_Linux by M. Garret.

LIST=$(ls *.mp3)
j=0
for i in $LIST; do
ORIG=$i
if j not in {2,7,8} # this I don't know how to do it.
then mplayer ORIG
fi
j=j+1
done

Kind regards.

Last edited by stf92; 06-07-2010 at 07:24 AM.
 
Old 06-07-2010, 08:41 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The easiest way may be to produce two files. The first containing the MP3s in the directory. The second containing the files to skip.

ls *.mp3 >songlist

echo >skiplist
songa.mp3
songe.mp3
songf.mp3
[PRESS CTRL-D TO QUIT TYPING]

Next remove the skiplist items from songlist:
grep -v -f skiplist songlist >playlist
mplayer $(cat playlist)
 
Old 06-07-2010, 11:35 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Hi, jshiwal.
There is a difficulty with your solution. And it is that the file names are very long, full with white space and containing the German letter B (something like Greek letter beta). So the construction of file skiplist would be tedious . But I can always edit it with an editor like vi. Most kind of you, anyways.
 
Old 06-07-2010, 10:08 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Moved to Programming
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy/move files and skip... Skillz Linux - General 15 09-28-2009 09:58 AM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
WMV Files skip when playing timothyb89 Linux - Software 2 10-05-2006 06:53 PM
Crystal PnP wave files skip Lone Wolf1979 Mandriva 0 03-22-2004 01:19 PM
How do I have tar skip files already on destination HD? Bob Ross Red Hat 2 02-04-2004 12:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration