;PURPOSE
;
;To search through all of the fits files in a given directory and extract 
;the date they were created from each of the headers.  The dates are printed
;to stdout along with the filenames.

pro fits_get_date_from_headers, FitsDir=FitsDir, Criteria=Criteria

if N_Elements(FitsDir)  eq 0 then FitsDir = '.'
if N_Elements(Criteria) eq 0 then Criteria = '*'
cd,FitsDir
FitsFiles = file_search(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, 'ACQDATE')
  print, 'File: '+file_basename(FitsFiles(i))+' , '+Date

endfor 

end 
