Hi folks, first of all please help me then i'm going to describe my
difficulty,
I guess it's a very simple case but unfortunately not for me becasue
I'm a beginner not only in idl but also in general programming.
PROBLEM:
I have a list of files all with the same name and I would like to make
a copy in a common folder. To avoid overwriting I have to rename each
file, e.g. with a progressive number. Basically, I have three steps:
(i) make a list of files, (ii) rename each file (file_move) (iii) and
then copy file_copy.
I'm assuming that I should repeat the process inside a loop for each
file
DIFFICULTY:
In the last copying step I'm not able to define the correct syntax for
the file_copy function.
Do you think that my approach is completed wrong? Is it a more
complicated case and should use another solution?
I'm re****ting the codes that I wrote:
;GET LIST OF FILES
Path = 'C:\source\'
list = file_search(Path,'spectra.txt)
;FILE LIST ORDED
str_num = stregex(list, '[0-7]+.std', /extract)
idx = sort(str_num)
list_orded = list[idx]
;READ IN ORDER THE FILE LIST
for i=0, n_elements(list_orded)-1 do begin
;DEFINE DIRECTORY OUTPUT
fdir='C:\destination\spectra'
;DEFINE A SUFFIX FOR THE OUTFILE NAME
suffix=strcompress(string(i),/remove_all)
a=strlen(suffix)
for k=0,2-a do suffix='0'+suffix
out_fname=fdir+suffix +'.std'
;(III) COPY FILES ????? I think I should inset the loop's index
"i" and copy to out_fname
file_copy, i, out_fname
endfor
end
Thanks in advance, Cico


|