Robert Dober
7/25/2007 12:35:00 PM
On 7/25/07, Peter Bailey <pbailey@bna.com> wrote:
> Why is it that File.basename works for me for one single file, but, it
> doesn't work for an array of files. Here's an example of what worked for
> me for one file; then, it didn't work for multiple files.
>
> Thanks,
> Peter
>
>
> file = "va998.tif"
> pdffile = File.basename(file, ".tif") + ".pdf"
> puts "#{file} #{pdffile}"
>
> yields:
> va998.tif va998.pdf
>
>
> Dir.glob("*.tif").each do |tiffile|
> pdffile = File.basename(tiffile, ".tif") + ".pdf"
> puts "#{tiffile} #{pdffile}"
> end
>
> yields:
>
> va992.tif va992.tif.pdf
> va993.tif va993.tif.pdf
> va994.tif va994.tif.pdf
> ...
> --
I could not reproduce the error, just after touching 1.tif and 2.tif I ran
505/5 > touch 1.tif
robert@PC:~/tmp/x 14:31:10
506/6 > touch 2.tif
robert@PC:~/tmp/x 14:31:14
507/7 > irb
irb(main):001:0> Dir.glob("*.tif").each do |tiffile|
irb(main):002:1* pdffile = File.basename(tiffile, ".tif") + ".pdf"
irb(main):003:1> puts "#{tiffile} #{pdffile}"
irb(main):004:1> end
1.tif 1.pdf
2.tif 2.pdf
=> ["1.tif", "2.tif"]
irb(main):005:0>
???
Really strange
I got:
508/8 > ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
and you?
Robert
--
I always knew that one day Smalltalk would replace Java.
I just didn't know it would be called Ruby
-- Kent Beck