summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/ruby/pdftools.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/pdftools.rb')
-rw-r--r--Master/texmf-dist/scripts/context/ruby/pdftools.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/pdftools.rb b/Master/texmf-dist/scripts/context/ruby/pdftools.rb
index d40e2d85281..6dfa47374d4 100644
--- a/Master/texmf-dist/scripts/context/ruby/pdftools.rb
+++ b/Master/texmf-dist/scripts/context/ruby/pdftools.rb
@@ -739,13 +739,23 @@ 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("")
report("#{n.to_s.rjust(4)} pages in total")
end
@@ -791,7 +801,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 +811,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')