Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > IDL > Copy and rename...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 188 of 235
Post > Topic >>

Copy and rename list of files all with the same name

by cico <ggs25@[EMAIL PROTECTED] > Jul 5, 2007 at 04:45 AM

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
 




 3 Posts in Topic:
Copy and rename list of files all with the same name
cico <ggs25@[EMAIL PRO  2007-07-05 04:45:25 
Re: Copy and rename list of files all with the same name
cico <ggs25@[EMAIL PRO  2007-07-06 03:35:57 
Re: Copy and rename list of files all with the same name
jnettle1@[EMAIL PROTECTED  2007-07-13 12:19:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 3:56:25 CDT 2008.