# How to make Dir.glob method NOT case sensitive

**URL:** <https://rubytalk.org/t/how-to-make-dir-glob-method-not-case-sensitive/14469>\
**Category:** ruby-talk\
**Created:** [28 October 2004 21:08 UTC](https://rubytalk.org/t/how-to-make-dir-glob-method-not-case-sensitive/14469 "2004-10-28T21:08:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kurt\_Euler1](https://avatars.discourse-cdn.com/v4/letter/k/d26b3c/32.png) [@Kurt\_Euler1](https://rubytalk.org/u/Kurt_Euler1)\
**Post date:** [28 October 2004 21:08 UTC](https://rubytalk.org/t/how-to-make-dir-glob-method-not-case-sensitive/14469/1 "2004-10-28T21:08:20Z")

</div>

All-

Can anyone advise as to how to make the Dir.glob method NOT case  
sensitive.

For example, in the following routine, I'd like to find all  
"PCM\_OP\*.XML" and "pcm\_op\*.xlm" occurances in the specified directory:

&nbsp;&nbsp;for f in Dir.glob("m:/some\_directory/\*\*/PCM\_OP\*.XML")  
&nbsp;&nbsp;&nbsp;&nbsp;next unless File.file?(f)  
&nbsp;&nbsp;&nbsp;&nbsp;count = count + 1  
&nbsp;&nbsp;&nbsp;&nbsp;puts File.dirname(f) + "/" + File.basename(f)  
&nbsp;&nbsp;end

Thanks!

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [28 October 2004 21:21 UTC](https://rubytalk.org/t/how-to-make-dir-glob-method-not-case-sensitive/14469/2 "2004-10-28T21:21:46Z")

</div>

> All-
> 
> Can anyone advise as to how to make the Dir.glob method NOT case  
> sensitive.
> 
> For example, in the following routine, I'd like to find all  
> "PCM\_OP\*.XML" and "pcm\_op\*.xlm" occurances in the specified directory:

See Dir.glob and File.fnmatch in ri

> &nbsp;&nbsp;for f in Dir.glob("m:/some\_directory/\*\*/PCM\_OP\*.XML")

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dir.glob("m:/some\_directory/\*\*/PCM\_OP\*.XML", File::FNM\_CASEFOLD)

> **···**
>
> On Oct 28, 2004, at 2:08 PM, Kurt Euler wrote:
> 
> > &nbsp;&nbsp;&nbsp;&nbsp;next unless File.file?(f)  
> > &nbsp;&nbsp;&nbsp;&nbsp;count = count + 1  
> > &nbsp;&nbsp;&nbsp;&nbsp;puts File.dirname(f) + "/" + File.basename(f)  
> > &nbsp;&nbsp;end
