image processing - Multi-file to Multi-page TIFF from large collection -
struggling consolidate multiple files multi-page tiffs using pyliff, libtiff, or work.
i'm consolidating thousands of files arbitrary 8 digit ids followed page numbers:
directory named date \images\1999\10\14
group of files 1 01234567_0001.tif, 01234567_0002.tif, 01234567_0003.tif
group of files 2 07654321_0001.tif, 07654321_0002.tif
following conversion i'd have 2 files:
- 01234567.tif (3 page mulipage tiff file)
- 07654321.tif (2 page multipage tiff file)
and on. please give guidance on script , consolidation segregate first 8 digits, merge files unique 8 digit number, , rename new (consolidated) file appropriate 8-digit-number.tiff
i realize seems without effort. have many disparate scripts , approaches muddy waters of forum.
the solution ruby able provide (imagemagick did conversion). hope helpful others:
#!/usr/bin/env ruby require 'find' require 'set' start_path = argv.shift || "~\desktop\in" output_path = argv.shift || "~\desktop\out" unless file.exist? start_path raise "cannot catalog contents; '#{start_path}' not exist" end unless file.exist? output_path raise "cannot catalog contents; '#{output_path}' not exist" end #make sure output directory has trailing slash unless output_path =~ /\\$/ output_path += "\\" end documents = set.new #look @ each file find.find(start_path) |file_path| #look document pattern if file_path =~ /^(.*?(\d{8}))_\d{4}.tif/ #track can unique document list documents.add({:path => $1, :name => $2}) end end documents.each |doc| command = "convert #{doc[:path]}*.tif* #{output_path}#{doc[:name]}.tif" puts command `#{command}` end
Comments
Post a Comment