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.
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.
p Dir.glob("*.tif").map {|f| File.basename(f, ".tif")}
and see if either one looks visibly funny.
martin
···
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.
Seems it is time to upgrade to 1.8.6, although I am not sure at all
that this will fix your problem.
Maybe there are some control characters at the end of the filenames of
the original tiff file?
No idea how to check this on Windows, but in Ruby you could check it like this:
Dir.glob("*.tif").each do |tiffile|
···
On 7/26/07, Peter Bailey <pbailey@bna.com> wrote:
> Works for me - what ruby version and OS? Try
>
> p Dir.glob("*.tif")
>
> p Dir.glob("*.tif").map {|f| File.basename(f, ".tif")}
>
> and see if either one looks visibly funny.
>
> martin
Both lines yield the same TIFF files. The second one shows the same TIFF
files, too, with the extension still there.
--
Posted via http://www.ruby-forum.com/\.
########################
puts "I got you" unless /tif$/ === tiffile
########################
pdffile = File.basename(tiffile, ".tif") + ".pdf"
puts "#{tiffile} #{pdffile}"
end
hmm does not seem possible, but try anyway
Cheers
Robert
--
[...]as simple as possible, but no simpler.
-- Attributed to Albert Einstein
Dir.glob("*.tif").each do |tiffile|
########################
puts "I got you" unless /tif$/ === tiffile
########################
pdffile = File.basename(tiffile, ".tif") + ".pdf"
puts "#{tiffile} #{pdffile}"
end
hmm does not seem possible, but try anyway
Cheers
Robert
Thanks, Robert. I did upgrade to 1.8.6. But, using your suggestion here,
I get the same. Using my code above, I get the same, too.
...
I got you
VA996.TIF VA996.TIF.pdf
end
puts
I got you
VA997.TIF VA997.TIF.pdf
end
puts
I got you
VA998.TIF VA998.TIF.pdf
end
...
> Dir.glob("*.tif").each do |tiffile|
> ########################
> puts "I got you" unless /tif$/ === tiffile
> ########################
> pdffile = File.basename(tiffile, ".tif") + ".pdf"
>
> puts "#{tiffile} #{pdffile}"
> end
>
> hmm does not seem possible, but try anyway
>
> Cheers
> Robert
Thanks, Robert. I did upgrade to 1.8.6.
That is a good thing anyway,
But, using your suggestion here,
I get the same. Using my code above, I get the same, too.
...
I got you
VA996.TIF VA996.TIF.pdf
end
puts
I got you
VA997.TIF VA997.TIF.pdf
end
puts
I got you
VA998.TIF VA998.TIF.pdf
end
...
--
Posted via http://www.ruby-forum.com/\.
what about case? In your case I think that Glob pulls them in
uppercase and you check for lowercase...
Robert
···
On 7/26/07, Peter Bailey <pbailey@bna.com> wrote:
--
[...] as simple as possible, but no simpler.
-- Attributed to Albert Einstein