pro Selrename If ( !version.os eq 'Win32' ) Then st = '\' If ( !version.os eq 'linux' ) Then st = '/' ;put .final and txt fts together:cp *.final /home/cao/NSTdata/sp/20120521/ Print,'Where are the files?' dir_read = DIALOG_PICKFILE( /DIRECTORY ) path = dir_read list_final = FILE_SEARCH(path, '*.final', count=nfls) pos = STRPOS(list_final[0], '.final') list = STRMID(list_final, 0, pos) nlist = FILE_SEARCH(path, 'irim*.fts') npos = STRPOS(nlist[0], '_sel') nlist = STRMID(nlist, 0, npos) ir = FLTARR(1024,1024) CLOSE, /ALL FOR i = 0, nfls-1 DO BEGIN hdr = RD_TEXT(list[i]+'.txt') hdr[2] = 'NAXIS = 2 /'+STRING(BYTARR(48)+32b) hdr[15] = 'TELE = NST /'+STRING(BYTARR(48)+32b) hdr[17] = 'OBS = WENDA CAO, Zhicheng Zeng /'+STRING(BYTARR(48)+32b) hdr[22] = 'EXPO = 0.014 sec /'+STRING(BYTARR(48)+32b) hdr[32] = 'WAVE = 1083 nm /'+STRING(BYTARR(48)+32b) OPENR, 1, list[i]+'.final' READU, 1, ir CLOSE, 1 WRITEFITS, nlist[i]+'_sp.fts', ir, hdr PRINT, list[i] PRINT, nlist[i] ENDFOR end