2010/8/23 Ralph Shnelvar <ralphs / dos32.com>:
> Assume I have a file pattern
> =A0temp*.bat
>
> Assume I have a directory d:\XXX
>
> and that I want to find all instances using Windows' file matching mechan=
isms rather than than Ruby regular expressions or the functionality of fnma=
tch.
>
> In other words ... it _has_ to be the Windows file matching method exactl=
y.

What exactly do you mean by "Windows file matching method"?  Windows
uses globbing very similar to most Unix shells.  So as long as you
stick with using "*" and "?" you can just use Dir.glob or Dir.[].

> I see that FileUtils has a bunch of functionality but what I want is some=
thing like
>
> =A0X_FileUtils.dir("MyDir").pattern("*.bat") { |file| puts file }
>
>
> Is there a gem "out there" to do what I want?

For the pattern above you only need

batches =3D Dir['MyDir/*.bat']

or if you want to get fancy:

batches =3D Dir[File.join('MyDir', '*.bat')]

For the fully recursive version you can do

batches =3D Dir['MyDir/**/*.bat']

and be done.  No Gems required.  You can even do

batches =3D Dir['MyDir/**/*.{bat,cmd}']

and really get all Windows batch files.

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/