LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-14-2006, 05:05 AM   #1
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Rep: Reputation: 47
how many mp3s?


I want to see how many mp3s I have on my Slackware 11 server. It doesn't have X installed. I've been using df -h for years and that gives an overall view of your mounted partition space. Could I use it to tell me how many mp3 files are on /mnt/mp3?
 
Old 11-14-2006, 05:20 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,644

Rep: Reputation: 145Reputation: 145
It can take longer if you have lots of them, but it should do the trick:
find /path/where/to/search -type f -iname "*mp3" | wc -l

EDIT: I just noticed that this probably is not what you are looking for. I interpreted "how many" as the number of mp3s rather than the space they are taking on your harddisk. Should have read better :-|

Last edited by titopoquito; 11-14-2006 at 05:42 AM.
 
Old 11-14-2006, 07:57 AM   #3
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,644

Rep: Reputation: 145Reputation: 145
You can cd to /mnt/mp3 and issue "du -h", the last number will give you the overall size of the folder. This won't give you the size of your mp3 files only, if you have other files like cover images etc. saved there too. A quick hack I created out of curiosity:

Code:
find /mnt/mp3  -type f -iname "*mp3" -exec ls -al "{}" \; > ~/mp3-space
cat ~/mp3-test | cut -d" " -f5 > ~/mp3-space2 
while read individual; do total=$(($total+$individual)); done < ~/mp3-space2; echo All mp3 files take $total bytes on /mnt/mp3
rm ~/mp3-space ~/mp3-space2
I could bet someone will give you a better script after (s)he has seen my [ironical] simple and elegant [/ironical] script.
 
Old 11-14-2006, 08:16 AM   #4
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 37
Shoudln't a
Code:
find /mnt/mp3 -type f -iname "*mp3" | du -hc
tell the size of all mp3 files in /mnt/mp3?


Edit: Ah but the file sizes aren't listed with find... need to use ls for that I think...
Some more adept at bash can solve this properly

Last edited by Zmyrgel; 11-14-2006 at 08:18 AM.
 
Old 11-14-2006, 08:45 AM   #5
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
You could use xargs here
Code:
find /mnt/mp3 -type f -iname "*mp3" -print0 | xargs -0 du -hc
 
Old 11-14-2006, 09:31 AM   #6
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
I don't want the size of the mp3 files. I'd like to know how many mp3 files I have...should be thousands of files.

Last edited by linuxhippy; 11-14-2006 at 09:34 AM.
 
Old 11-14-2006, 10:42 AM   #7
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
Quote:
Originally Posted by titopoquito
It can take longer if you have lots of them, but it should do the trick:
find /path/where/to/search -type f -iname "*mp3" | wc -l
This worked well-thanks!
 
Old 11-14-2006, 12:02 PM   #8
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
Instead of using find for this many files, could I use locate or slocate for speed?
 
Old 11-14-2006, 12:36 PM   #9
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Yes. The locate man page describes the '-r' and '-i' switches. But given a sufficiently large database and a sufficiently small and targeted audio file hierarchy, it's possible locate could be slower. Not likely, but just saying...
 
Old 11-14-2006, 01:29 PM   #10
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
I just experimented with a couple files (I'm not at my mp3 server), but this seems to work quick:

slocate *.mp3 | wc -l

How could I refine that to only search in /mnt/mp3? Is that -r or -i?
 
Old 11-14-2006, 01:52 PM   #11
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
This works on a couple files and is quick:

slocate -d=/mnt/mp3 *.mp3 | wc -l
 
Old 11-14-2006, 02:50 PM   #12
linuxhippy
Senior Member
 
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207

Original Poster
Rep: Reputation: 47
I wound up using the find command (it was quick on my 200 MHz CPU) and got 5722 with:

find /mnt/mp3 -type f -iname "*.mp3" | wc

Thanks for all the help!!
 
  


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
mp3s from different HD Fr4@k Linux - Newbie 3 10-09-2003 12:42 PM
mp3s Juice Linux - Newbie 4 03-16-2003 01:58 PM
MP3s Pongo Linux - Newbie 3 11-19-2002 03:03 AM
mp3s killer_siller Linux - General 10 08-08-2002 11:34 AM
rippers, mp3s and mp3s.... (?) bxb32001 Linux - General 0 07-14-2001 12:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:19 PM.

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