Gabriel Dragffy
8/23/2007 12:31:00 PM
On 23 Aug 2007, at 12:54, Stefano Crocco wrote:
> Alle giovedì 23 agosto 2007, Gabriel Dragffy ha scritto:
>> Just another quicky, if I wanna rename all the files in the directory
>> is what I did OK, using:
>> next if f=="." or f==".."
>>
>> I just feel there must a better way?
>
> If you want to rename only files, then you should do
>
> next unless File.file? f
>
> This way, you skip not only the given directory and its parent, but
> also any
> directory inside the current. If you're sure the given directory
> contains
> only files, then you're approach and mine should be equivalent
> (although, in
> my opinion, mine makes clearer why you're skipping those entries).
>
> Stefano
>
Aha yes, perhaps in my situation both equal, but yours is surely
cleaner and in another situation it would save me from nuking the
subdirs. Thank you, Stefano.