comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Copy file to all subfolders
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Copy file to all subfolders [message #90925 is a reply to message #90923] Wed, 13 May 2015 01:22 Go to previous messageGo to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den onsdag 13 maj 2015 kl. 09:04:18 UTC+2 skrev Kai Heckel:
> Am Dienstag, 12. Mai 2015 16:57:05 UTC+2 schrieb David Fanning:
>> Kai Heckel writes:
>>
>>> Yep I tried the FILE_COPY function but it didn't work...
>>> e.g. I tried this line:
>>>
>>> FILE_COPY, DIALOG_PICKFILE(Title='Select file: '), file_dirs
>>>
>>> -> file_dirs is a variable that contains all subfolders
>>
>> Yeah, the documentation is probably leading you astray. I'd use it in a
>> loop. Mats will show you how now that he is in the right frame of
>> reference. ;-)
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>
> So I tried this:
>
> FOR i=0, N_ELEMENTS(file_dirs)-1 do
> spawn, 'cp ', 'myfile', file_dirs[i]
> ENDFOR
>
> ...somehow this won't work. This maybe an absolute newbie thing but I acutally am new to IDL and programming in general. ;)

The spawn command wants a single string so you should concatenate the parts of the command you want to execute. Also, if myfile is a variable containing the file name, it should not be in quotes.

Doing something like this in the loop makes it easier to see that you get the command string right:

cmd= 'cp ' + myfile + ' ' + file_dirs[i]
print, cmd
spawn,cmd
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Plot southern coordinates in northen map
Next Topic: % Program caused arithmetic error: Floating illegal operand

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:00:59 PDT 2025

Total time taken to generate the page: 0.00401 seconds