# This program counts directories and files based on specific parameters set in # the grep argument (i.e. "\.tif" - extracts tif files) and wc -l then counts # the number of occurrences per line of the specified grep argument. The user # presented with a menu of choices: number of: 1)sub-directories 2)files # 3)tif 4)gif 5)jpg 6)r.jpg 7)t.gif 8)sgm x)[...] files, where ...file extension # Clears the screen first tput clear print "You must be in the appropriate directory from which you wish to count the number of subdirectories or files." print "The current directory is: $(pwd)" print " Press Enter to Continue\c" read while true do # Clears the screen first tput clear print " MAIN MENU cd) Change Directory 1) number of sub-directories in tree 2) number of files in tree 3) number of "tif" files in tree 4) number of "gif" files in tree 5) number of "jpg" files in tree 6) number of "r.jpg" files in tree 7) number of "t.gif" files in tree 8) number of "sgm" files in tree x) number of [...] files, where ... is the file extension 9) Quit Choice==> \c" read answer case ${answer} in # Change current directory to another directory cd) print "Type in the Full Path of the directory you wish to change to by starting with a forward slash (/) (i.e. /pnp/pan ) : \c" read directory cd ${directory} print "Current Directory is: $(pwd)" # pwd print "Press Enter to Continue" read ;; # directories 1) li -OdR | wc -l print "Press Enter to Continue" read ;; # files 2) li -OfR | wc -l print "Press Enter to Continue" read ;; # tif 3) ls -lR | grep "\.tif" | wc -l print "Press Enter to Continue" read ;; # gif 4) ls -lR | grep "\.gif" | wc -l print "Press Enter to Continue" read ;; # jpg 5) ls -lR | grep "\.jpg" | wc -l print "Press Enter to Continue" read ;; # r.jpg 6) ls -lR | grep "\r.jpg" | wc -l print "Press Enter to Continue" read ;; # t.gif 7) ls -lR | grep "\t.gif" | wc -l print "Press Enter to Continue" read ;; # sgm 8) ls -lR | grep "\.sgm" | wc -l print "Press Enter to Continue" read ;; # This part of the Program allows the user to count the number of files based on# the type of file, determined by extension (i.e. .mpg, .mov, ...) x) print "Enter the file extension you want to count; excluding the [.]" read input ls -lR | grep "\.${input}" | wc -l print "Press Enter to Continue" read ;; # Quits program [9Qq]) exit ;; # Error Routine Comment *) print "not a valid input" read ;; esac done