Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Copy Source | Copy HTML require 'find' require 'fileutils' require 'RMagick' def image_sort (unsort_path, sort_path) count = 0 if ! File .directory?(sort_path) FileUtils .mkdir sort_path end if File .directory?(unsort_path) Find .find(unsort_path) { |fname| if /\.(jpg|png|gif)$/i =~ fname count += 1 img = Magick::Image::read(fname).first wh_dir_name = img.columns.to_s + 'x' + img.rows.to_s if ! File .directory?(sort_path + wh_dir_name) FileUtils .mkdir sort_path + wh_dir_name end FileUtils .cp(fname, sort_path + wh_dir_name) puts fname + ' copied' end } else puts unsort_path + ' not found' end puts count .to_s + ' file(s) copied' end puts 'Path to pictures: ' pd = gets pd. chomp ! puts 'Path to new sort directory: ' sd = gets sd. chomp ! image_sort ( pd, sd )
Source: https://habr.com/ru/post/85609/
All Articles