# Moving Files from a CGI Script

**URL:** <https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143>\
**Category:** Ruby\
**Created:** [June 12, 2006, 5:56pm UTC](https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143 "2006-06-12T17:56:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/91b2a8/32.png) [@nko](https://www.ruby-forum.com/u/nko)\
**Post date:** [June 12, 2006, 5:56pm UTC](https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143/1 "2006-06-12T17:56:59Z")

</div>

I’m looking to use a CGI script to move / rename a directory. I can’t  
find anything under Dir:: or File:: that looks appropriate and making a  
shell command `in back-ticks` is out of the question as I’m using POST  
data to determine which directory to move. What’s the appropriate  
mechanism for moving files in Ruby?

---

<div class="post-metadata">

**Author:** ![nko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/91b2a8/32.png) [@nko](https://www.ruby-forum.com/u/nko)\
**Post date:** [June 12, 2006, 6:09pm UTC](https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143/2 "2006-06-12T18:09:38Z")

</div>

On Tue, 13 Jun 2006, Nathan O. wrote:

> I’m looking to use a CGI script to move / rename a directory. I can’t  
> find anything under Dir:: or File:: that looks appropriate and making a  
> shell command `in back-ticks` is out of the question as I’m using POST  
> data to determine which directory to move. What’s the appropriate  
> mechanism for moving files in Ruby?

ri FileUtils

-a

---

<div class="post-metadata">

**Author:** ![nko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/91b2a8/32.png) [@nko](https://www.ruby-forum.com/u/nko)\
**Post date:** [June 12, 2006, 6:10pm UTC](https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143/3 "2006-06-12T18:10:06Z")

</div>

Nathan O. wrote:

> I’m looking to use a CGI script to move / rename a directory. I can’t  
> find anything under Dir:: or File:: that looks appropriate and making a  
> shell command `in back-ticks` is out of the question as I’m using POST  
> data to determine which directory to move. What’s the appropriate  
> mechanism for moving files in Ruby?

Will FileUtils::mv do what you want?

---

<div class="post-metadata">

**Author:** ![nko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/91b2a8/32.png) [@nko](https://www.ruby-forum.com/u/nko)\
**Post date:** [June 12, 2006, 6:16pm UTC](https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143/4 "2006-06-12T18:16:09Z")

</div>

Alex Y. wrote:

> Will FileUtils::mv do what you want?

FileUtils looks perfect! Thanks. Every time I feel like I’m getting  
somewhere with Ruby, I find out I’ve been missing some obvious bit the  
whole time. I couldn’t even find this on Google!

---

<div class="post-metadata">

**Author:** ![nko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/91b2a8/32.png) [@nko](https://www.ruby-forum.com/u/nko)\
**Post date:** [June 12, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143/5 "2006-06-12T18:32:12Z")

</div>

On Tue, 13 Jun 2006, Nathan O. wrote:

> Alex Y. wrote:
> 
> > Will FileUtils::mv do what you want?
> 
> FileUtils looks perfect! Thanks. Every time I feel like I’m getting  
> somewhere with Ruby, I find out I’ve been missing some obvious bit the  
> whole time. I couldn’t even find this on Google!

download the source. look in the lib/ dir. it’s all there.  
alternatively  
use

[http://ruby-doc.org/](http://ruby-doc.org/)

it’s all there too.

-a

---

<div class="post-metadata">

**Author:** ![nko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/91b2a8/32.png) [@nko](https://www.ruby-forum.com/u/nko)\
**Post date:** [June 12, 2006, 6:43pm UTC](https://www.ruby-forum.com/t/moving-files-from-a-cgi-script/63143/6 "2006-06-12T18:43:38Z")

</div>

unknown wrote:

> [http://ruby-doc.org/](http://ruby-doc.org/)
> 
> it’s all there too.

That’s the first place I looked. I glossed over the modules listed below  
File without thinking about it. There were a lot of them, and usually in  
a situation like that, I end up going down a lot of dead-end roads. Just  
goes to show what I get for being cynical!
