Skip to content

Instantly share code, notes, and snippets.

@dominiceden
Created November 28, 2015 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominiceden/e9373aa71c486ca65bb6 to your computer and use it in GitHub Desktop.
Save dominiceden/e9373aa71c486ca65bb6 to your computer and use it in GitHub Desktop.
This Ruby script will copy files from one directory to another with a small delay. This is useful for the Shopify Theme application for example, which will not upload files if they are copied all at once into a directory. By uploading them one by one with a delay, you can still upload them all and save time if you have lots of files.
require 'fileutils'
# Replace Dominic with your actual user name. Use 'pwd' command to find this if you're not sure.
source_dir = Dir["/Users/Dominic/Downloads/sourcedirectory/*.*"] # Get all files with any extension in the folder 'sourcedirectory'
source_dir.each do |item|
FileUtils.cp(item, '/Users/Dominic/Documents/targetdirectory/') # Copy the item in the loop to the folder 'targetdirectory'
sleep(5) # Wait 5 seconds before moving on to the next item in the loop.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment