17
18
19
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
48
49
50
51
52
53
54
55
|
# File 'lib/photo-helper/delete.rb', line 17
def jpeg(folder = nil)
folder ||= options[:folder]
puts folder
search_path = File.expand_path(folder)
jpeg_path = File.join(search_path, 'jpegs')
files =
if options[:recursive]
Dir["#{search_path}/**/*.{#{JPEG_EXTENSIONS.join(',')}}"]
else
Dir["#{search_path}/*.{#{JPEG_EXTENSIONS.join(',')}}"]
end
files.each do |file|
has_raw = false
RAW_EXTENSIONS.each do |extension|
raw_file_name = "#{File.basename(file.to_s, '.*')}.#{extension}"
has_raw = true if File.exist? File.join(File.dirname(file.to_s), raw_file_name)
end
next unless has_raw
next if FileHelper.ingore_file?(file)
puts file
if options[:softdelete]
File.trash(file)
else
File.delete(file)
end
end
return unless File.exist?(jpeg_path) && yes?('Delete jpeg folder?')
say 'Deleting jpeg folder', :red
if options[:hard]
File.delete(jpeg_path)
else
File.trash(jpeg_path)
end
end
|