Forum: Ruby Re: File basenames using File.basename . . .

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Berger, Daniel (Guest)
on 2006-04-13 16:39
(Received via mailing list)
> -----Original Message-----
> From: list-bounce@example.com
> [mailto:list-bounce@example.com] On Behalf Of Peter Bailey
> Sent: Thursday, April 13, 2006 5:57 AM
> To: ruby-talk ML
> Subject: Re: File basenames using File.basename . . .

<snip>

> 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
B58c6eef325656d513d26e2c3ae6bfd9?d=identicon&s=25 Peter Bailey (peterbailey)
on 2006-04-13 19:21
Berger, Daniel wrote:
>> -----Original Message-----
>> From: list-bounce@example.com
>> [mailto:list-bounce@example.com] On Behalf Of Peter Bailey
>> Sent: Thursday, April 13, 2006 5:57 AM
>> To: ruby-talk ML
>> Subject: Re: File basenames using File.basename . . .
>
> <snip>
>
>> 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.
This topic is locked and can not be replied to.