summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/ruby/pdftools.rb21
-rw-r--r--scripts/context/ruby/pstopdf.rb8
2 files changed, 22 insertions, 7 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')
diff --git a/scripts/context/ruby/pstopdf.rb b/scripts/context/ruby/pstopdf.rb
index 55bfa3365..3625f4d83 100644
--- a/scripts/context/ruby/pstopdf.rb
+++ b/scripts/context/ruby/pstopdf.rb
@@ -42,7 +42,10 @@ class Commands
def main
filename = @commandline.argument('first')
pattern = @commandline.option('pattern')
- globfiles(pattern) if filename.empty? && ! pattern.empty?
+ if filename.empty? && ! pattern.empty? then
+ pattern = "**/#{pattern}" if @commandline.option('recurse')
+ globfiles(pattern)
+ end
filename = @commandline.argument('first')
if filename.empty? then
help
@@ -344,7 +347,7 @@ class Commands
# report("processing non ps/pdf file #{filename}")
handle_magick(magick,filename)
else
- report("option not suported for #{filename}")
+ report("option not supported for #{filename}")
end
end
@@ -509,6 +512,7 @@ commandline.registervalue('outputpath')
commandline.registerflag('watch')
commandline.registerflag('force')
+commandline.registerflag('recurse')
commandline.registervalue('delay',2)