On Jul 6, 6:35 am, cico <gg...@[EMAIL PROTECTED]
> wrote:
> Hi again guys, just to communicate that i resolved my issue, i'm
> re****ting the correct code
>
> ;GET LIST OF FILES
> Path = 'C:\source\'
> list = file_search(Path,'spectra.txt)
>
> ;READ IN ORDER THE FILE LIST
> for i=0, n_elements(list_orded)-1 do begin
>
> ;DEFINE OUTPUT DIRECTORY\FOLDER
> fdir='C:\destination\spectra'
>
> ;MAKING A PROGRESSIVE SUFFIX FOR THE OUTFILE
> suffix=strcompress(string(i),/remove_all)
> a=strlen(suffix)
> for k=0,2-a do suffix='0'+suffix
> out_fname=fdir+suffix +'.std'
>
> ;STARTS COPY PROCESS
> file_copy,list[i],out_fname
>
> ;PRINTS NUMBER FILE COPIED
> print,'spectrum copied=',[i]
>
> bye, cico
I'm not quite sure how you got your list of input files, but I think
you can do this without a loop, which will be faster. In IDL
programming it's good practice to avoid loops wherever possible as
they are very slow in IDL. Even when I know code written with a loop
won't take very long to execute, I still try to write vectorized
programs to keep me in the mindset of avoiding loops. So, assuming
your list of files is in the variable infiles:
i = indgen(n_elements(infiles))
ext = strtrim(string(i),2) + '.txt'
outfiles = file_basename(infiles, '.txt) + ext
file_copy, infiles, outfiles
I can't test this b/c i don't have your list of input filenames, but I
think it should work. Or be very close to something that should
work :)
Jeff


|