20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/media_archiver/cli.rb', line 20
def copy(*paths)
config = configurations(options)
paths.each do |path|
path = File.expand_path(path)
MediaFileUtils.new(path).each(config[:recursive]) do |file|
dest = output_path(file, config[:output_dir], config[:output_template])
FileUtils.mkdir_p(File.dirname(dest))
output = ["File: #{dest}"]
output << if File.exist?(dest)
if config[:overwrite_extensions].empty? || !config[:overwrite_extensions].include?(dest.split('.').last.downcase)
'[SKIP]'
else
FileUtils.cp(file.path, dest)
'[OVERWRITE]'
end
else
FileUtils.cp(file.path, dest)
'[OK]'
end
puts output.join(' ')
end
end
end
|