LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-04-2008, 12:15 AM   #1
swift2008
Member
 
Registered: Jul 2008
Posts: 78

Rep: Reputation: 15
find the number of files in a folder


hi all
i have a folder "images".
it contains a lot of images/files.
how to know the number of images/files in that folder.
 
Old 08-04-2008, 12:22 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
find /path/to/images/folder -type f | wc -l
 
Old 08-04-2008, 02:02 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If its just the one single level dir,

ls|wc -l
 
Old 08-04-2008, 02:06 AM   #4
swift2008
Member
 
Registered: Jul 2008
Posts: 78

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
If its just the one single level dir,

ls|wc -l
thank you. it is very helpful
 
Old 10-28-2009, 08:51 AM   #5
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908
Blog Entries: 26

Rep: Reputation: 49
how to find files & subfolders inside a folder using command

I have taken clue from previous post & come up with simplest way

Finding number of files in a folder
find . -type f | wc -l
this means output of find comand (which is only files no directories)is sent to wc which counts number of lines i.e number of files

Finding number of subfolders in a folder
(1)find . -type d | wc -l
This will give number of subfolders+1 because current folder also gets included.Note that the folders inside subfolders are also included in count.
(2)If you want to see only number of folders in current folder then
find . -maxdepth 1 -type d | wc -l
Here output is numberof subfolders+1
NOTE:folders inside subfolders not considered.

If this information helps you please thank me by pressing thumbs up button.Happy hacking.

Last edited by sumeet inani; 10-28-2009 at 08:52 AM.
 
Old 10-25-2010, 03:22 AM   #6
blck_kenzo
LQ Newbie
 
Registered: Nov 2007
Posts: 15

Rep: Reputation: 0
Quote:
Originally Posted by Mr. C. View Post
find /path/to/images/folder -type f | wc -l
It work well. Thanks for your support !
 
  


Reply



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 find the total number of files in a folder cnm Linux - Newbie 18 08-25-2015 01:01 AM
Find out the number of files currently opened closet geek Linux - Kernel 5 05-19-2015 08:19 AM
Linux API to find out the number of USB disks connected to the machine and the files poomas Linux - Newbie 2 04-29-2008 09:04 AM
Maximum number of files in a folder in Linux lionking_x Linux - Newbie 2 12-08-2007 10:54 PM
Find 100 largest files in folder tree tyreth Linux - General 2 02-07-2006 08:18 AM

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

All times are GMT -5. The time now is 07:47 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