Ever find yourself with 100 KMZ files that you want to edit or do something with that requires KML files? Well, I did and here is my solution. I already had 7-zip installed and wrote a quick bit of Ruby to run through all the KMZ files in a certain folder and unzip them into KML files. Assuming you have Runy and 7-zip isntalled and the path to 7-zip is "C:/Program Files/7-Zip/7z.exe" thsi should work as long as you change the path to the location of your KMZ files. Also, the "File.move" line is only applicable if (as in my case) the KML files in all the KMZ files are named doc.kml, if they have unique names this line is unnecessary.
#!/usr/bin/ruby
require "ftools"
#Make this the path to your KMZ files
path = "D:/Data/kmz_files"
d = Dir.new(path)
d.each{|file|
if file.match(/.kmz$/) then
system("C:/Program Files/7-Zip/7z.exe e #{file}")
#This next line is only applicable if the KML files in all
#the KMZ files are named doc.kml
File.move("#{path}/doc.kml", "#{path}/#{file.gsub('.kmz', '.kml')}" , verbose=true)
end
}
#Tested Against: ruby 1.8.2 (2004-12-25) [i386-mswin32]