Parsing files and writing about them . .

A number of you all helped me to get to the point of actually being able
to write a RUBY script, period. Now, I’m trying to concatenate all that
I’ve learned and put it into an iterative script. Here it is. It doesn’t
error out, but, it also doesn’t do anything! It just executes. I do
believe my regex is legitimate. I want it to parse postscript files and
then pipe information about blank pages in those .ps files to other
files, the “.pageinfo” files.

Thanks.

Dir.chdir(“c:/scripts/ruby/temp”)
psfiles = Dir.glob(’*.ps’)
numberofblanks = []
blankpages = []
psfiles.each do |psfile|
File.read(psfile).scan(/%%Page: ([\d()]+)
(\d{1,5})\n%%PageBoundingBox:
\d{1,5} \d{1,5} \d{1,5} \d{1,5}\n%%PageOrientation:/) do
blankpages.push($1)
numberofblanks.push($2)
unless numberofblanks.empty?
infofile = File.basename(psfile, ‘.ps’)
File.open(“infofile + .pageinfo”, “w”) do |writetext|
writetext << “Number of blanks in this PDF:
#{numberofblanks.length}\n”
<< “Blank Pages in This PDF: #{blankpages.join(’ ')}\n”
end
end
end

Peter B. wrote:

A number of you all helped me to get to the point of actually being able
to write a RUBY script, period. Now, I’m trying to concatenate all that
I’ve learned and put it into an iterative script. Here it is. It doesn’t
error out, but, it also doesn’t do anything! It just executes. I do
believe my regex is legitimate. I want it to parse postscript files and
then pipe information about blank pages in those .ps files to other
files, the “.pageinfo” files.

Thanks.

Dir.chdir(“c:/scripts/ruby/temp”)
psfiles = Dir.glob(’*.ps’)
numberofblanks = []
blankpages = []
psfiles.each do |psfile|
File.read(psfile).scan(/%%Page: ([\d()]+)
(\d{1,5})\n%%PageBoundingBox:
\d{1,5} \d{1,5} \d{1,5} \d{1,5}\n%%PageOrientation:/) do
blankpages.push($1)
numberofblanks.push($2)
unless numberofblanks.empty?
infofile = File.basename(psfile, ‘.ps’)
File.open(“infofile + .pageinfo”, “w”) do |writetext|
writetext << “Number of blanks in this PDF:
#{numberofblanks.length}\n”
<< “Blank Pages in This PDF: #{blankpages.join(’ ')}\n”
end
end
end

Never mind. I actually figured this out myself. I’m so proud. Thanks,
anyway!