Skip to content

Instantly share code, notes, and snippets.

@madeindjs
Created October 14, 2016 15:06
Show Gist options
  • Save madeindjs/555607b461ba7c81691cb62789854eb2 to your computer and use it in GitHub Desktop.
Save madeindjs/555607b461ba7c81691cb62789854eb2 to your computer and use it in GitHub Desktop.
Synchronize Sketchup files between two directory
if File.extname(file) == '.skp'
file_src  = File.join $remote_path, file
file_dest  = File.join $model_path, file
# if file already exists but a newer version exists on remote, we add it
if File.exists?(file_dest) and ( File.mtime(file_src).to_i > File.mtime(file_dest).to_i )
FileUtils.cp(file_src, file_dest)
puts "[*] #{file} %s" % $lHandler['updated']
yield "#{file} %s" % $lHandler['updated']
# if file not exists we add it to the local library
elsif not File.exists? file_dest
FileUtils.cp(file_src, file_dest)
puts "[*] #{file} %s" % $lHandler['added']
yield "#{file} %s" % $lHandler['added']
# else already up to date
else
puts "[ ] #{file} already up to date"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment