# Re: File basenames using File.basename . .

**URL:** <https://www.ruby-forum.com/t/re-file-basenames-using-file-basename/57738>\
**Category:** Ruby\
**Created:** [April 13, 2006, 4:39pm UTC](https://www.ruby-forum.com/t/re-file-basenames-using-file-basename/57738 "2006-04-13T16:39:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 13, 2006, 4:39pm UTC](https://www.ruby-forum.com/t/re-file-basenames-using-file-basename/57738/1 "2006-04-13T16:39:18Z")

</div>

> -----Original Message-----  
> From: removed\_email\_address@domain.invalid  
> [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Peter B.  
> Sent: Thursday, April 13, 2006 5:57 AM  
> To: ruby-talk ML  
> Subject: Re: File basenames using File.basename . . .

> Thanks, Dan. Both of your suggestions worked for me. Now, how could I  
> fulfill my instructions in the filesystem itself, not just in  
> the array?  
> I know I can do it with a system(“ren \*.txt \*.”), but, how  
> would I do it  
> in RUBY?

To rename individual files, use File.rename. For batches of files I’m  
not sure off the top of my head, but I’m guessing there’s a method in  
either FileUtils or ftools.

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 13, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/re-file-basenames-using-file-basename/57738/2 "2006-04-13T19:21:11Z")

</div>

Berger, Daniel wrote:

> > -----Original Message-----  
> > From: removed\_email\_address@domain.invalid  
> > [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Peter B.  
> > Sent: Thursday, April 13, 2006 5:57 AM  
> > To: ruby-talk ML  
> > Subject: Re: File basenames using File.basename . . .
> 
> > Thanks, Dan. Both of your suggestions worked for me. Now, how could I  
> > fulfill my instructions in the filesystem itself, not just in  
> > the array?  
> > I know I can do it with a system(“ren \*.txt \*.”), but, how  
> > would I do it  
> > in RUBY?
> 
> To rename individual files, use File.rename. For batches of files I’m  
> not sure off the top of my head, but I’m guessing there’s a method in  
> either FileUtils or ftools.
> 
> Regards,
> 
> Dan

Makes sense. Thanks.
