# FileUtils in widows

**URL:** <https://www.ruby-forum.com/t/fileutils-in-widows/110656>\
**Category:** Ruby\
**Created:** [July 29, 2007, 12:03am UTC](https://www.ruby-forum.com/t/fileutils-in-widows/110656 "2007-07-29T00:03:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [July 29, 2007, 12:03am UTC](https://www.ruby-forum.com/t/fileutils-in-widows/110656/1 "2007-07-29T00:03:43Z")

</div>

I am fairly new to ruby and am working with windows xp. I’m trying to  
copy files from one directory to another using the FileUtils module.  
When I run the program, I get a Permission Denied error (EACCES). Any  
thoughts on how to get this to work?

files.each do |f|  
next if f == “.” or f == “…”  
FileUtils.copy(dir,newdir)  
end

Thanks in advance for any help.

jjd

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [July 29, 2007, 12:16am UTC](https://www.ruby-forum.com/t/fileutils-in-widows/110656/2 "2007-07-29T00:16:16Z")

</div>

On Jul 28, 5:03 pm, Jonathan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am fairly new to ruby and am working with windows xp. I’m trying to  
> copy files from one directory to another using the FileUtils module.  
> When I run the program, I get a Permission Denied error (EACCES). Any  
> thoughts on how to get this to work?
> 
> files.each do |f|  
> next if f == “.” or f == “…”  
> FileUtils.copy(dir,newdir)

You forgot to use f in this line.

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [July 29, 2007, 12:23am UTC](https://www.ruby-forum.com/t/fileutils-in-widows/110656/3 "2007-07-29T00:23:58Z")

</div>

> > files.each do |f|  
> > next if f == “.” or f == “…”  
> > FileUtils.copy(dir,newdir)
> 
> You forgot to use f in this line.

Isn’t the f covered in the do statement? I’m not sure how else f would  
be implemented.

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [July 29, 2007, 2:01am UTC](https://www.ruby-forum.com/t/fileutils-in-widows/110656/4 "2007-07-29T02:01:26Z")

</div>

On Jul 29, 8:24 am, Jon D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > files.each do |f|  
> > > next if f == “.” or f == “…”  
> > > FileUtils.copy(dir,newdir)
> 
> > You forgot to use f in this line.
> 
> Isn’t the f covered in the do statement? I’m not sure how else f would  
> be implemented.

FileUtils.copy(f, newdir)

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [July 29, 2007, 2:44am UTC](https://www.ruby-forum.com/t/fileutils-in-widows/110656/5 "2007-07-29T02:44:11Z")

</div>

Gavin S. wrote:

> On Jul 29, 8:24 am, Jon D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > > files.each do |f|  
> > > > next if f == “.” or f == “…”  
> > > > FileUtils.copy(dir,newdir)
> > 
> > > You forgot to use f in this line.

> FileUtils.copy(f, newdir)

Thanks, works now. I stared at it so long I couldn’t see the obvious!

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [July 29, 2007, 2:51am UTC](https://www.ruby-forum.com/t/fileutils-in-widows/110656/6 "2007-07-29T02:51:29Z")

</div>

On Jul 28, 6:58 pm, Gavin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> FileUtils.copy(f, newdir)

Or  
FileUtils.copy( “#{dir}/#{f}”, newdir)

FileUtils.copy isn’t a mind-reader.  
It doesn’t know (or assume) that you have put  
the name of the file in variable named f.  
It doesn’t know that it is being invoked  
inside of a loop.
