Convert MacSHAPA Files to Work in Datavyu

Convert MacSHAPA Files to Work in DatavyuΒΆ

MacSHAPA users can convert their files to the new Datavyu format using a script. The following script converts a folder of MacSHAPA files to Datavyu files but be sure to edit your folders’ names and locations to reflect the location of your MacSHAPA files and Datavyu files.

require 'Datavyu_API.rb'
begin

   # Edit this to match the directory containing your files.
   macshapa_folder = File.expand_path("~/Desktop/MacSHAPA/")
   macshapa_files = Dir.new(macshapa_folder)

   # Edit this to match where you want to save the datavyu files.
   datavyu_folder = File.expand_path("~/Desktop/Datavyu/")
   if (!File::directory?(datavyu_folder))
       Dir.mkdir(datavyu_folder) # Make this dir if it doesn't exist
   end

   for f in macshapa_files.each()
    # Filter out files we don't want
        if (f[0].chr != '.') # Filter out the hidden files like . and .. and .DSSTORE
            puts "Converting " + f
            # Load the file and don't draw it to the screen
            $db, proj = load_macshapa_db(macshapa_folder + '/' + f, false)
            puts "Saving file " + f + " as Datavyu file."
            save_db(datavyu_folder + '/' + f + ".opf")
        end
   end
end