Welcome, Guest
Username Password: Remember me

find a number of file in directories recursively
(1 viewing) (1) Guest
Shell Script
  • Page:
  • 1

TOPIC: find a number of file in directories recursively

find a number of file in directories recursively 1 year, 4 months ago #523

  • scmuser
  • OFFLINE
  • Gold Boarder
  • scm master
  • Posts: 237
  • Points: 3429
  • Karma: 0
  • Honor Medal 2009
I have several directories and files underneath...how to find only files from all directories...

any command

Re: find a number of file in directories recursively 1 year, 4 months ago #524

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44589
  • Karma: 4
  • Honor Medal 2009
Try following command

find ./ -type f | wc -l


For finding only files from all directories recursively

find ./ - type d | wc -l


For finding only directory om all directories recursively
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar

Re: find a number of file in directories recursively 1 year, 3 months ago #562

  • opendesk
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Points: 17
  • Karma: 0
From DOS Command prompt, you can do:

dir /A-d /b /s

or in java, you need to do recursion. Here is a java code snippet.

public void visitAllFiles(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();

for (int i = 0; i < children.length; i++) {
visitAllFiles(new File(dir, children[i]));
}
} else {
processFiles(dir);
}
}

All the best :)

Re: find a number of file in directories recursively 1 year, 2 months ago #577

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44589
  • Karma: 4
  • Honor Medal 2009
Good Input.. Thanks a lot.
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar
  • Page:
  • 1
Time to create page: 0.92 seconds

     
    
Home Forum