Skip to content

Instantly share code, notes, and snippets.

@funwarioisii
Last active February 26, 2023 05:44
Show Gist options
  • Save funwarioisii/cddf44744c9cb1a348f504ee16b8349e to your computer and use it in GitHub Desktop.
Save funwarioisii/cddf44744c9cb1a348f504ee16b8349e to your computer and use it in GitHub Desktop.
This is a script that uploads files from an external storage device connected to macOS to Google Cloud Storage and copies them to the appropriate directory based on their file type.
def execute? = ENV["EXECUTE"] == '1'
date = Time.now.strftime("%Y%m%d")
sources = Dir.glob("/Volumes/Untitled/DCIM/*")
gcs_path = "gs://funwarioisii-photo-backup"
sources.each do |source|
command = "gcloud storage cp #{source}/* #{gcs_path}/original/#{date}"
print "RUN: #{command}\n"
if execute?
`#{command}`
end
end
command = "gcloud storage cp '#{gcs_path}/original/#{date}/*.MOV' #{gcs_path}/movie && gcloud storage cp '#{gcs_path}/original/#{date}/*.MOV' #{gcs_path}/movie"
print "RUN: #{command}\n"
if execute?
`#{command}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment