X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 19 Aug 2009 12:20 PM by  anon
out_name
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
19 Aug 2009 12:20 PM
    I would like to read everything in my input folder and output everything to a new folder using the code below. However, I am not sure how to change out_name to get it to do this and if I am doing the correct thing in reading all the files in. pro outputtoexternalfile FORWARD_FUNCTION ENVI_OPEN_DATA_FILE  compile_opt strictarr  ENVI, /RESTORE_BASE_SAVE_FILES ;envi_batch_init, log_file='E:\FinalProcessing\GrassValley_Slide\burn_indices\batch.log' ;set up path to input and output files input_path = 'E:\test090819\in\' output_path='E:\test090819\out\'     ; search for data files in the specified directory     files = FILE_SEARCH(input_path, '*',count=count)     IF (count EQ 0) THEN BEGIN   PrintF, 'No files were found to process'  ENDIF ;open file    for i=0, count-1 do begin     ENVI_OPEN_FILE, files[i], r_fid=refl_fid      if (refl_fid eq -1) then begin       envi_batch_exit       return      endif ENVI_FILE_QUERY, refl_fid, ns=ns, nl=nl, nb=nb, data_type=data_type, fname=filename    pos=lindgen(nb)    dims=[-1L,0, ns-1, 0, nl-1] OUT_NAME = output_path+filename+'test' ENVI_OUTPUT_TO_EXTERNAL_FORMAT, dims = dims, /ESRI_GRID, FID=refl_FID, pos=pos, OUT_NAME=out_name endfor end

    Deleted User



    New Member


    Posts:
    New Member


    --
    19 Aug 2009 03:31 PM
    When you call ENVI_FILE_QUERY and use the fname keyword, what's going to end up stored in the variable 'filename' (in this case) is going to be the full path to the input file.  But then you prepend the output directory onto that, and then append the string 'test', so i don't think you're creating a valid output path.  For example, if your input filename is 'E:\test090819\in\input_file.img', then you turn the out_name into this: E:\test090819\out\E:\test090819\in\input_file.imgtest because of the way you're constructing OUT_NAME.  IDL has several quick and easy debugging methods available for you, so that you never have to be unsure for long about which variable is holding what information.  For example, in your case, putting these two lines: print, OUT_NAME return after you construct OUT_NAME would print out exactly what it is then stop the program.  you could also substitute ".stop" for "return", which would let you .continue your code if you want to let it try to complete after you print out out_name.

    Deleted User



    New Member


    Posts:
    New Member


    --
    19 Aug 2009 04:12 PM
    Thank you. So how do I change the out_name to keep the file name but change the filepath?
    You are not authorized to post a reply.