pro ls_to_batch ; ; writes a batch file, based on contents of selected ls file ; ; adds program name, then parses input file and adds to output directory ; to make output file name. ; ; for running with dither_combine.pro for lots of images ; ; DPC 20051102 original code ; batch_name = dialog_pickfile(Title="Select a file to hold this batch input file") file_in = dialog_pickfile(Title="Select the input list file") pro_name = '' print,"Enter the name of the program to run for each list file entry" read,pro_name pro_name = STRTRIM(pro_name,2) ; dir_out = dialog_pickfile(Title="Select the directory for Output Images",/DIRECTORY) ; ; open the batch file ; openw, lu_batch, batch_name, /GET_LUN ; ; for each input entry, ; openr, lu_in, file_in, /GET_LUN ; while (~EOF(lu_in)) do begin path = '' readf, lu_in, path path = STRTRIM(path,2) ; ; extract the filename -- not easy, with embedded periods (dots) ; dirname = FILE_DIRNAME(path) dirlen = STRLEN(dirname) ; filename = STRMID(path,dirlen+1) ; print, "path = ",path print, "dir = ",dirname print, "file = ",filename ; ; strip off .dat and add .fits ; filelen = STRLEN(filename) root = STRMID(filename, 0, filelen-4) ; print, "root = ",root filename = root + ".FITS" ; outpath = dir_out + filename ; print, "outpath = ",outpath ; ; write the line to the batch file ; printf, lu_batch, format='(a,1h;,a,1h;,a)',pro_name,path,outpath endwhile FREE_LUN,lu_in FREE_LUN,lu_batch ; print, "LS to Batch is Done!" end