On Oct 20, 11:12 pm, forgottenwizard <phrexianrea... / hushmail.com> wrote: > This is an odd problem, I admit. I'm currently working on a short script > to sort a set of JPEGs by size, but right now I'm just trying to move > them from point A to point B (I'm still learning Ruby, so I do this to > try and figure things out before getting into the big stuff), and so far > I have gotten so far as: > > ####################CODE#################### > > #!/usr/bin/ruby -wd > > require "RMagick" > require "fileutils" > > Dir.chdir(ARGV[0]) > > for pix in Dir.glob("*.{jpeg,jpg,png}") > filetype = Magick::Image::read(pix).first.format > workdir = Dir.pwd > If File.directory?(filetype) then Are you telling us that this is the exact code that you ran? It can't be. Ruby is case-sensitive. It's "if", not "If". How did "If" get into this code? Didn't you copy and paste? Or did you retype it? > FileUtils.move("#{pix}", "#{workdir}/#{filetype}") > else > Dir.mkdir(filetype) > FileUtils.move("#{pix}", "#{workdir}/#{filetype}") > end > end require "fileutils" Dir.chdir( ARGV[0] ) workdir = Dir.pwd Dir[ "*.{jpeg,jpg,png}" ].each{|pix| filetype = File.extname( pix )[1..-1] Dir.mkdir( filetype ) if not File.exists?( filetype ) FileUtils.move( pix, "#{workdir}/#{filetype}" ) }