#!/bin/tcsh

# script.csh - Simple tcsh example.
# Eric Saunders, April 2007



# $1 is the first argument provided to the shellscript. 
# This script expects it to be a directory.

# $2 is a file extension, e.g. 'pdf'

# Make sure we get 2 arguments...
if ( $#argv < 2 ) then
   echo Usage: ${0} dirname extension
   exit 1
endif

# Check the directory actually exists...
if ( ! -e $1 ) then
   echo WARNING: Directory \'$1\' does not exist - exiting.
   exit 1
endif

# Find the number of matching files...
set nfiles = `ls $1/*.$2 | wc -w`

echo $nfiles files found in dir \'$1\' matching extension \'$2\'...

# Print them out...
foreach file ($1/*.pdf)
   echo $file
end
