;PURPOSE
;
;To search through all of the fits files in a given directory and extract 
;a certain keyword from all of their headers.  The value is printed 
;to stdout along with the filenames.
;
;KEYWORDS:
;   KeyWord - The fits header keyword that will be used.  The value of this
;             will be extracted from all files in FitsDir and printed to the 
;             terminal
;
pro fits_get_keyword_from_headers, FitsDir=FitsDir, KeyWord=Keyword, $
    Criteria=Criteria

if N_Elements(FitsDir)  eq 0 then FitsDir = './'
if N_Elements(Criteria) eq 0 then Criteria = '*'
cd,FitsDir
FitsFiles = file_search(FitsDir, Criteria+'*.fits')
NumFitsFiles = N_Elements(FitsFiles)

for i = 0, NumFitsFiles -1 do begin
  fits_read, FitsFiles(i), no_data, h, /header_only 
  Date = sxpar(h, KeyWord)
  print, 'File: '+file_basename(FitsFiles(i))+' , '+string(Date)

endfor 

end 
