[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

check if file exists for part of the filename

Christian Kerth

3/14/2008 8:33:00 AM

Hey!

How do i check if a file exists, that starts with a certain identifier?

e.g. Files in Directory

file_1.rb
file_2.rb
test_1.rb

I only want to know if a file exists, that starts with "file_"

thx
--
Posted via http://www.ruby-....

5 Answers

Mark Bush

3/14/2008 9:02:00 AM

0

Christian Kerth wrote:
> I only want to know if a file exists, that starts with "file_"

Dir.entries('.').detect {|f| f.match /^file_/}

Replace '.' with the name of the directory to check if it is not the
current directory. Will return the name of the first file to match if
there is one, else will return nil.

--
Posted via http://www.ruby-....

Peña, Botp

3/14/2008 9:05:00 AM

0

W21haWx0bzpsaXN0LWJvdW5jZUBleGFtcGxlLmNvbV0gT24gQmVoYWxmIE9mIENocmlzdGlhbiBL
ZXJ0aA0KIyBIb3cgZG8gaSBjaGVjayBpZiBhIGZpbGUgZXhpc3RzLCB0aGF0IHN0YXJ0cyB3aXRo
IGEgY2VydGFpbiANCiMgaWRlbnRpZmllcj8NCiMgZS5nLiBGaWxlcyBpbiBEaXJlY3RvcnkNCiMg
ZmlsZV8xLnJiDQojIGZpbGVfMi5yYg0KIyB0ZXN0XzEucmINCiMgSSBvbmx5IHdhbnQgdG8ga25v
dyBpZiBhIGZpbGUgZXhpc3RzLCB0aGF0IHN0YXJ0cyB3aXRoICJmaWxlXyINCg0KdGhlcmUgYXJl
IG1hbnkgd2F5cy4gDQp0aGVzZSBhcmUganVzdCBzb21lLi4uDQoNCkRpci5nbG9iKCJmaWxlXyou
cmIiKS5lbXB0eT8NCiM9PiBmYWxzZQ0KDQpEaXIuZ2xvYigiZmlsZV8qLnJiIikuc2l6ZT4wDQoj
PT4gdHJ1ZQ0KDQpEaXIuZ2xvYigiZmlsZV8qLnJiIikNCiM9PiBbImZpbGVfMS5yYiIsICJmaWxl
XzIucmIiLCAiZmlsZV8zLnJiIl0NCg0KRmlsZS5leGlzdD8gImZpbGVfMS5yYiINCiM9PiB0cnVl
DQoNCkZpbGUuZXhpc3Q/ICJmaWxlXzIucmIiDQojPT4gdHJ1ZQ0KDQpGaWxlLmV4aXN0PyAiZmls
ZV80LnJiIg0KIz0+IGZhbHNlDQoNCg0Ka2luZCByZWdhcmRzIC1ib3RwDQo=

Daniel Tonks

11/20/2010 5:24:00 AM

0

Mike M. in MI <mikemuglia@hotmail.com> wrote:
> It looks like you have shaker motors again. :)
>
> What's the difference in the Rev B shaker motor vs the original?
>
> Mike

Rev B includes a wire harness needed for Stern's newer games (they cut out a
small chunk of wire that lead from the back to the front of the cabinet).

- Dan


Mike M. in MI

11/20/2010 5:26:00 AM

0

Thanks!

So if I just bought IM, I would need Rev B?

Mike

Daniel Tonks

11/20/2010 5:33:00 AM

0

Mike M. in MI <mikemuglia@hotmail.com> wrote:
> Thanks!
>
> So if I just bought IM, I would need Rev B?
>
> Mike

Definitely. I believe it's needed going back to IJ4.

- Dan