I have been busy playing around with more than 100,000 images and JPG files from my hard drive and I just realized that I was issuing a few set of commands redundantly specially on counting the number of images from categorical 'named' folders alone and from its sub 'event-folders' recursively.
Here's how to find and count JPG image files from subdirectories recursively.
Assuming a list of thousand JPG image files
# cd /images
# ls -la
result:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drwxr-xr-x 51 root root 4096 2008-02-25 18:10 image00001
..
snip
drwxr-xr-x 51 root root 4096 2008-02-25 18:10 image99999
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From current working folder location, start finding and counting JPG files
# find . -name "*.jpg" | wc -l
By default, the command find searches JPG files recursively on current working directory. It should be able to find the supplied search filename.
Alternatively, creating an alias with the same command could also be convenient
# alias countjpg='find . -name "*.jpg" | wc -l'
Just remember to make it permanent between reboots by simply appending it to your ~/bashrc file.
Other prefers it to be coming from their own bash shell script
# cat /bin/countjpg.sh
output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/bash
clear
echo Recursively counting JPG files on current folder $(pwd) ...
find . -name "*.jpg" | wc -l
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# chmod 700 /bin/countjpg.sh
# countjpg.sh
That is all, enjoy.
Few Most Popular Articles:
Watch and Play 113 Amazing Linux Games?
Enabling Sun Java on Fedora 8
50 Quick Linux Tips Part 1
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2008
(2301)
-
▼
February
(25)
- HowTo: Extract Lines That Started With Matching St...
- HowTo: Delete All Thumbs.db Recursively
- HowTo: Handy Linux Network Diagnostic Tool
- HowTo: Display Lines That Starts With A Given String
- HowTo: Find And Count JPG Files Recursively
- HowTo: Do Awk with Loop
- HowTo: Strip Out First Word of Line from Text Files
- HowTo: Highlight Matching Grep Results
- HowTo: GNOME Commander File Manager
- HowTo: Install Plone CMS on Fedora
- HowTo: Thumbnail A Website From Linux Command Term...
- HowTo: Advanced Two-Pane File Manager
- HowTo: Two-Pane GUI File Manager
- Slash Proc - File System Utilities
- HowTo: Drop Down Linux Terminal Console
- HowTo: Image Magics with ImageMagick
- HowTo: Convert JPG Image Files to MPG Video Files
- HowTo: Alternative Way to Convert GIF to PNG
- HowTo: Lock X While Root With ScreenSaver
- HowTo: Encrypted Bandwidth-Efficient Linux Backup ...
- HowTo: Install Java IcedTea on Fedora 8
- HowTo: Simultaneous Install of Sun Java and Java I...
- HowTo: Install K9Copy on Fedora
- HowTo: More of Fedora Themes Package
- HowTo: European Language Fonts Installation on Fedora
-
▼
February
(25)
Tuesday, February 26, 2008
HowTo: Find And Count JPG Files Recursively
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment