Re: File basenames using File.basename . .

a different extension for a separate write file. I’ve tried this:

txtfiles = Dir.glob(".txt")
txtfiles.each { |txtfile| File.basename(“txtfile”, "
.txt") }

Remove the quotes around txtfile.
Change “*.txt” to just “.txt”.

Regards,

Dan

Berger, Daniel wrote:

a different extension for a separate write file. I’ve tried this:

txtfiles = Dir.glob(".txt")
txtfiles.each { |txtfile| File.basename(“txtfile”, "
.txt") }

Remove the quotes around txtfile.
Change “*.txt” to just “.txt”.

Regards,

Dan

Thanks, Dan. I still get the same thing, though:
irb(main):008:0> txtfiles.each { |txtfile| File.basename(txtfile,
“.txt”) }

=> [“eula.txt”, “libcurl.COPYING.txt”, “openssl.LICENSE.txt”,
“psout2.txt”, “run
dll32.exe.Z-missing.txt”]

This gets the same result, too:

irb(main):012:0> txtfiles.each { |txtfile| File.basename(txtfile, “.*”)
}

=> [“eula.txt”, “libcurl.COPYING.txt”, “openssl.LICENSE.txt”,
“psout2.txt”, “run
dll32.exe.Z-missing.txt”]