comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Copy file to all subfolders
items: Re: Copy file to all subfolders

Copy file to all subfolders
type: item
description: Hey there! I'd like to copy a file to all contained subfolders. The structure looks something like this: MAIN_FOLDER (contains the file that is supposed to be copied) : : - Subfolder1 - Subfolder2 - Subfolder3 I thought about using a FOR-loop but that didn't work out yet. Would really appreciate your help here! Thanks
creator: Kai Heckel
date: 2015-05-12T13:56:25-00:00

Re: Copy file to all subfolders
type: item
description: Den tisdag 12 maj 2015 kl. 15:56:27 UTC+2 skrev Kai Heckel: > Hey there! > > I'd like to copy a file to all contained subfolders. > The structure looks something like this: > > MAIN_FOLDER (contains the file that is supposed to be copied) > : > : > - Subfolder1 > - Subfolder2 > - Subfolder3 > > I thought about using a FOR-loop but that didn't work out yet. > > Would really appreciate your help here! > > Thanks You could use something like subfolders=file_search('MAIN_FOLDER/Subfolder?',count=Nfolde rs) for i=0,Nfolders-1 do spawn,'cp '+filename+' '+subfolders[i]
creator: Mats Löfdahl
date: 2015-05-12T14:29:49-00:00

Re: Copy file to all subfolders
type: item
description: Mats Löfdahl writes: > You could use something like > > subfolders=file_search('MAIN_FOLDER/Subfolder?',count=Nfolde rs) > for i=0,Nfolders-1 do spawn,'cp '+filename+' '+subfolders[i] Or, for an IDL solution, FILE_COPY. ;-) 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.")
creator: David Fanning
date: 2015-05-12T14:33:09-00:00

Re: Copy file to all subfolders
type: item
description: Am Dienstag, 12. Mai 2015 15:56:27 UTC+2 schrieb Kai Heckel: > Hey there! > > I'd like to copy a file to all contained subfolders. > The structure looks something like this: > > MAIN_FOLDER (contains the file that is supposed to be copied) > : > : > - Subfolder1 > - Subfolder2 > - Subfolder3 > > I thought about using a FOR-loop but that didn't work out yet. > > Would really appreciate your help here! > > Thanks 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
creator: Kai Heckel
date: 2015-05-12T14:37:33-00:00

Re: Copy file to all subfolders
type: item
description: Den tisdag 12 maj 2015 kl. 16:33:13 UTC+2 skrev David Fanning: > Mats Löfdahl writes: > >> You could use something like >> >> subfolders=file_search('MAIN_FOLDER/Subfolder?',count=Nfolde rs) >> for i=0,Nfolders-1 do spawn,'cp '+filename+' '+subfolders[i] > > Or, for an IDL solution, FILE_COPY. ;-) Who said anything about IDL? :o)
creator: Mats Löfdahl
date: 2015-05-12T14:48:35-00:00

Re: Copy file to all subfolders
type: item
description: Am Dienstag, 12. Mai 2015 15:56:27 UTC+2 schrieb Kai Heckel: > Hey there! > > I'd like to copy a file to all contained subfolders. > The structure looks something like this: > > MAIN_FOLDER (contains the file that is supposed to be copied) > : > : > - Subfolder1 > - Subfolder2 > - Subfolder3 > > I thought about using a FOR-loop but that didn't work out yet. > > Would really appreciate your help here! > > Thanks Thought this was an IDL forum :D But anyway thanks Mats!
creator: Kai Heckel
date: 2015-05-12T14:54:03-00:00

Re: Copy file to all subfolders
type: item
description: 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.")
creator: David Fanning
date: 2015-05-12T14:57:01-00:00

Re: Copy file to all subfolders
type: item
description: 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. ;)
creator: Kai Heckel
date: 2015-05-13T07:04:17-00:00

Re: Copy file to all subfolders
type: item
description: 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
creator: Mats Löfdahl
date: 2015-05-13T08:22:11-00:00

Re: Copy file to all subfolders
type: item
description: Am Mittwoch, 13. Mai 2015 10:22:12 UTC+2 schrieb Mats Löfdahl: > 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 Using that and other structures, IDL always prints that "FILE_DIRS with K is out of range.". "file_dirs" includes the full path to every folder that I want the data to be copied to. Still something wrong with the code? file_dirs = FILE_SEARCH(mydir, /TEST_DIRECTORY) myfile = DIALOG_PICKFILE(Title='Select myfile: ') FOR i=0, N_ELEMENTS(file_dirs)-1 do begin cmd = 'cp ' + myfile + '' + file_dirs[k] print, cmd spawn, cmd ENDFOR
creator: Kai Heckel
date: 2015-05-13T09:19:58-00:00

Re: Copy file to all subfolders
type: item
description: Den onsdag 13 maj 2015 kl. 11:20:00 UTC+2 skrev Kai Heckel: > Am Mittwoch, 13. Mai 2015 10:22:12 UTC+2 schrieb Mats Löfdahl: >> 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 > > Using that and other structures, IDL always prints that "FILE_DIRS with K is out of range.". "file_dirs" includes the full path to every folder that I want the data to be copied to. Still something wrong with the code? > > file_dirs = FILE_SEARCH(mydir, /TEST_DIRECTORY) > myfile = DIALOG_PICKFILE(Title='Select myfile: ') > FOR i=0, N_ELEMENTS(file_dirs)-1 do begin > cmd = 'cp ' + myfile + '' + file_dirs[k] > print, cmd > spawn…
creator: Mats Löfdahl
date: 2015-05-13T09:29:55-00:00

Re: Copy file to all subfolders
type: item
description: Am Mittwoch, 13. Mai 2015 11:29:56 UTC+2 schrieb Mats Löfdahl: > Den onsdag 13 maj 2015 kl. 11:20:00 UTC+2 skrev Kai Heckel: >> Am Mittwoch, 13. Mai 2015 10:22:12 UTC+2 schrieb Mats Löfdahl: >>> 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 >> >> Using that and other structures, IDL always prints that "FILE_DIRS with K is out of range.". "file_dirs" includes the full path to every folder that I want the data to be copied to. Still something wrong with the code? >> >> file_dirs = FILE_SEARCH(mydir, /TEST_DIRECTORY) >> myfile = DIALOG_PICKFILE(T…
creator: Kai Heckel
date: 2015-05-13T10:30:57-00:00

Re: Copy file to all subfolders
type: item
description: Am Mittwoch, 13. Mai 2015 12:30:59 UTC+2 schrieb Kai Heckel: > Am Mittwoch, 13. Mai 2015 11:29:56 UTC+2 schrieb Mats Löfdahl: >> Den onsdag 13 maj 2015 kl. 11:20:00 UTC+2 skrev Kai Heckel: >>> Am Mittwoch, 13. Mai 2015 10:22:12 UTC+2 schrieb Mats Löfdahl: >>>> 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 >>> >>> Using that and other structures, IDL always prints that "FILE_DIRS with K is out of range.". "file_dirs" includes the full path to every folder that I want the data t…
creator: Kai Heckel
date: 2015-05-13T10:58:42-00:00