summaryrefslogtreecommitdiff
path: root/scripts/context/ruby/pdftools.rb
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2006-12-12 23:46:00 +0100
committerHans Hagen <pragma@wxs.nl>2006-12-12 23:46:00 +0100
commit76b4e3623f8fc6da6b55444699e1f44ef35dfbec (patch)
treeeabb0587cb95c5069645a7481fca020135acce17 /scripts/context/ruby/pdftools.rb
parent2b32a603111531f0dd185fbb58bd103adf027c93 (diff)
downloadcontext-76b4e3623f8fc6da6b55444699e1f44ef35dfbec.tar.gz
stable 2006.12.12 23:46
Diffstat (limited to 'scripts/context/ruby/pdftools.rb')
-rw-r--r--scripts/context/ruby/pdftools.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/scripts/context/ruby/pdftools.rb b/scripts/context/ruby/pdftools.rb
index d40e2d852..cfcc39631 100644
--- a/scripts/context/ruby/pdftools.rb
+++ b/scripts/context/ruby/pdftools.rb
@@ -739,12 +739,21 @@ class Commands
end
def countpages
- filenames, n = findfiles('pdf'), 0
+ if @commandline.option('pattern') then
+ filenames, n = globfiles(@commandline.option('pattern'),'pdf'), 0
+ else
+ filenames, n = findfiles('pdf'), 0
+ end
+ threshold = @commandline.option('threshold').to_i rescue 0
filenames.each do |filename|
if `pdfinfo #{filename}`.chomp =~ /^pages\s*\:\s*(\d+)/mois then
- report("#{$1.rjust(4)} pages found in #{filename}")
- n += $1.to_i
- end
+ p = $1
+ m = p.to_i rescue 0
+ if threshold == 0 or m > threshold then
+ report("#{p.rjust(4)} pages found in #{filename}")
+ n += m
+ end
+ end
end
report("#{n.to_s.rjust(4)} pages in total")
end
@@ -791,7 +800,7 @@ commandline.registeraction('colorimage', 'filename --colorspec= [--retain -
commandline.registeraction('convertimage', 'filename [--retain --subpath]')
commandline.registeraction('downsampleimage', 'filename [--retain --subpath --lowres --normal]')
commandline.registeraction('info', 'filename')
-commandline.registeraction('countpages', 'pattern')
+commandline.registeraction('countpages', '[--pattern --threshold]')
commandline.registeraction('analyzefile' , 'filename')
@@ -801,6 +810,8 @@ commandline.registeraction('version')
commandline.registervalue('colorname')
commandline.registervalue('colorspec')
commandline.registervalue('subpath')
+commandline.registervalue('pattern')
+commandline.registervalue('threshold',0)
commandline.registerflag('lowres')
commandline.registerflag('medres')