P
Peter Bailey
Hi,
I'm baffled by this problem. If I define a single file, I can use gsub
to create the same name, with different extensions. But, when I do it
with a list of files, it doesn't work. Why is the code below giving me
nothing but .tif files, when, I'm asking for three different file types:
tif, png, and pdf?
Thanks,
Peter
Work with one. . . .
L:\tiff\cdtiff\47000>irb
irb(main):001:0> tiffile = "wy47089.tif"
=> "wy47089.tif"
irb(main):002:0> pngfile = tiffile.gsub(/\.tif/, ".png")
=> "wy47089.png"
irb(main):003:0> pdffile = tiffile.gsub(/\.tif/, ".pdf")
=> "wy47089.pdf"
irb(main):004:0> puts "#{tiffile} #{pngfile} #{pdffile}"
wy47089.tif wy47089.png wy47089.pdf
Doesn't work with many. . . .
L:\tiff\cdtiff\47000>irb
irb(main):001:0> Dir.glob("wy*.tif").each do |tiffile|
irb(main):002:1* pngfile = tiffile.gsub(/\.tif/, ".png")
irb(main):003:1> pdffile = tiffile.gsub(/\.tif/, ".pdf")
irb(main):004:1> puts "#{tiffile} #{pngfile} #{pdffile}"
irb(main):005:1> end
WY47040.TIF WY47040.TIF WY47040.TIF
WY47046.TIF WY47046.TIF WY47046.TIF
WY47050.TIF WY47050.TIF WY47050.TIF
WY47057.TIF WY47057.TIF WY47057.TIF
WY47089.TIF WY47089.TIF WY47089.TIF
=> ["WY47040.TIF", "WY47046.TIF", "WY47050.TIF", "WY47057.TIF",
"WY47089.TIF"]
I'm baffled by this problem. If I define a single file, I can use gsub
to create the same name, with different extensions. But, when I do it
with a list of files, it doesn't work. Why is the code below giving me
nothing but .tif files, when, I'm asking for three different file types:
tif, png, and pdf?
Thanks,
Peter
Work with one. . . .
L:\tiff\cdtiff\47000>irb
irb(main):001:0> tiffile = "wy47089.tif"
=> "wy47089.tif"
irb(main):002:0> pngfile = tiffile.gsub(/\.tif/, ".png")
=> "wy47089.png"
irb(main):003:0> pdffile = tiffile.gsub(/\.tif/, ".pdf")
=> "wy47089.pdf"
irb(main):004:0> puts "#{tiffile} #{pngfile} #{pdffile}"
wy47089.tif wy47089.png wy47089.pdf
Doesn't work with many. . . .
L:\tiff\cdtiff\47000>irb
irb(main):001:0> Dir.glob("wy*.tif").each do |tiffile|
irb(main):002:1* pngfile = tiffile.gsub(/\.tif/, ".png")
irb(main):003:1> pdffile = tiffile.gsub(/\.tif/, ".pdf")
irb(main):004:1> puts "#{tiffile} #{pngfile} #{pdffile}"
irb(main):005:1> end
WY47040.TIF WY47040.TIF WY47040.TIF
WY47046.TIF WY47046.TIF WY47046.TIF
WY47050.TIF WY47050.TIF WY47050.TIF
WY47057.TIF WY47057.TIF WY47057.TIF
WY47089.TIF WY47089.TIF WY47089.TIF
=> ["WY47040.TIF", "WY47046.TIF", "WY47050.TIF", "WY47057.TIF",
"WY47089.TIF"]