Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-14-2006, 05:05 AM
|
#1
|
Senior Member
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Rep:
|
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?
|
|
|
11-14-2006, 05:20 AM
|
#2
|
Senior Member
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 current
Posts: 1,649
Rep: 
|
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.
|
|
|
11-14-2006, 07:57 AM
|
#3
|
Senior Member
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 current
Posts: 1,649
Rep: 
|
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.
|
|
|
11-14-2006, 08:16 AM
|
#4
|
Senior Member
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006
Rep:
|
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.
|
|
|
11-14-2006, 08:45 AM
|
#5
|
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,824
|
You could use xargs here
Code:
find /mnt/mp3 -type f -iname "*mp3" -print0 | xargs -0 du -hc
|
|
|
11-14-2006, 09:31 AM
|
#6
|
Senior Member
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
|
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.
|
|
|
11-14-2006, 10:42 AM
|
#7
|
Senior Member
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
|
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!
|
|
|
11-14-2006, 12:02 PM
|
#8
|
Senior Member
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
|
Instead of using find for this many files, could I use locate or slocate for speed?
|
|
|
11-14-2006, 12:36 PM
|
#9
|
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113
Rep: 
|
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...
|
|
|
11-14-2006, 01:29 PM
|
#10
|
Senior Member
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
|
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?
|
|
|
11-14-2006, 01:52 PM
|
#11
|
Senior Member
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
|
This works on a couple files and is quick:
slocate -d=/mnt/mp3 *.mp3 | wc -l
|
|
|
11-14-2006, 02:50 PM
|
#12
|
Senior Member
Registered: Sep 2004
Location: Philadelphia, PA
Distribution: Xubuntu, Mythbuntu, Lubuntu, Picuntu, Mint 18.1, Debian Jessie
Posts: 1,207
Original Poster
Rep:
|
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!!
|
|
|
All times are GMT -5. The time now is 11:52 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|