Created
June 7, 2016 13:47
-
-
Save milothiesen/4157b3d061dffae4e38f902ff0a0a0f2 to your computer and use it in GitHub Desktop.
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
#developed by Maile Thiesen | |
#!/usr/bin/ruby | |
#help from http://stackoverflow.com/users/256970/cary-swoveland | |
#http://stackoverflow.com/questions/37571258/ruby-how-to-copy-files-to-a-specific-directory-if-the-file-does-not-exist/37681206#37681206 | |
require 'FileUtils' | |
library_path_1 = ARGV[0] | |
library_path_2 = ARGV[1] | |
library_path_3 = ARGV[2] | |
# check the managed media folder for files, look in original capture scratch for all files in managed media. | |
# if files in managed media exist in original capture scratch, copy them to the destination folder. | |
managed_media_folder = Dir.glob(library_path_1 + "/**/*").select{ |x| File.file? x } | |
original_capture_scratch = Dir.glob(library_path_2 + "/**/*").select{ |x| File.file? x } | |
destination = Dir.glob(library_path_3 + "/**/*").select{ |x| File.file? x } | |
bn = managed_media_folder.map { |fn| File.basename fn } - destination.map { |fn| File.basename fn } | |
original_capture_scratch.each do |fn| | |
if bn.include? File.basename(fn) | |
puts fn | |
FileUtils.cp(fn, library_path_3) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment