Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
news://news.gmane.org:119/d595839d148e500d97ab65e611365709@ruby-forum.com
#!/usr/bin/ruby
$orcafile1 = ARGV[0]
$orcafile2 = ARGV[1]
$url = "http://ps2000-graphics-prod.bna.com/view/"
def run(cmd)
puts cmd
`#{cmd}`
end
if $orcafile1 =~ /^p/ then
puts "This first file is a p file."
$prefix = $orcafile1[/^([A-z,0-9]{1,15}p)([0-9]{1,5})\.([A-z]{3,4})/]
$prefix = $1
$numeral1 = $2
$flavor = $3
$numeral2 = $orcafile2[/^[A-z,0-9]{1,15}p([0-9]{1,5})\.[A-z]{3,4}/]
puts $numeral2
if $flavor == "tif" then
$flavor = "tiff"
$extension = "tif"
end
for i in $numeral1..$numeral2
run "curl -o #{$prefix}0#{i}.#{$flavor} #{$url}#{$flavor}/#{$prefix}0#{i}" if i.to_i < 10
run "curl -o #{$prefix}#{i}.#{$flavor} #{$url}/#{$flavor}/#{$prefix}#{i}" if i.to_i > 9
end
else
$prefix = $orcafile1[/^([A-z]{1,5})([0-9]{1,6})\.([A-z]{3,4})/]
$prefix = $1
$numeral1 = $2
$flavor = $3
$extension = $3
$numeral2 = $orcafile2[/^[A-z]{1,5}([0-9]{1,6})\.[A-z]{3,4}/]
$numeral2 = $1
puts $numeral2
if $flavor == "tif" then
$flavor = "tiff"
$extension = "tif"
end
for i in $numeral1..$numeral2
run "curl -o #{$prefix}#{i}.#{$extension} #{$url}/#{$flavor}/#{$prefix}#{i}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment