From: Fily Salas Date: 2011-03-24T03:09:48+09:00 Subject: Problems moving and renaming pictures with this code, what wrong? Hi, I have been reading the book called “Learning to Program” and I have to say it, for beginners this is a great book, anyways, while practicing the exercises found in the book I came across this code that for some reason it doesn’t work. I have some .jpg pictures located in a folder called “temp-photos” in my desktop and I want to rename them and then move them to a folder which is also located in my desktop but in a folder called “my-photos” and I’m trying the code below but when I run it, it just doesn’t do anything, no errors but the pictures don’t get moved or renamed. Any idea what am I doing wrong? I don’t actually need this program but since I’m practicing I want to understand what’s going on. Thanks ---------------------------------------------- Dir.chdir '/Users/userName/Desktop/my-photos' pic_names = Dir['/Users/userName/Desktop/temp-photos.{JPG,jpg}'] puts 'What would you like to call this batch?' batch_name = gets.chomp puts print "Downloading #{pic_names.length} files: " pic_number = 1 pic_names.each do |name| print '.' new_name = if pic_number < 10 "#{batch_name}0#{pic_number}.jpeg" else "#{batch_name}#{pic_number}.jpeg" end File.rename name, new_name pic_number = pic_number + 1 end puts puts 'Done' -- Posted via http://www.ruby-forum.com/.