[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Coping all files in a folder

nicknewton

10/22/2007 1:55:00 PM

require 'ftools'

source="c:\\axis\\FTP storage"
dest="c:\\axis\\images"
For some reason this code will not work, I am not sure why. It will
get into the loop with the copy state meant and then error.

dir.each do|file|
copy= true
puts "#{file}"

stop=gets

if file=="."
copy=false
end

if file==".."
copy=false
end

if copy==true
puts "I'm in"
File.copy( "#{file}", "#{dest}")
end

Any advice on what I am doing wrong would be great, I am pretty new to
Ruby and programming in general.

Thanks
Nick

end

1 Answer

nicknewton

10/22/2007 2:08:00 PM

0

On Oct 22, 8:54 am, nick <nicknew...@gmail.com> wrote:
> require 'ftools'
>
> source="c:\\axis\\FTP storage"
> dest="c:\\axis\\images"
> For some reason this code will not work, I am not sure why. It will
> get into the loop with the copy state meant and then error.
>
> dir.each do|file|
> copy= true
> puts "#{file}"
>
> stop=gets
>
> if file=="."
> copy=false
> end
>
> if file==".."
> copy=false
> end
>
> if copy==true
> puts "I'm in"
> File.copy( "#{file}", "#{dest}")
> end
>
> Any advice on what I am doing wrong would be great, I am pretty new to
> Ruby and programming in general.
>
> Thanks
> Nick
>
> end

Figured it out using FileUtils.Copy, thank anyways