Created
November 28, 2015 17:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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