From: "Christopher D." Date: 2012-04-28T03:04:43+09:00 Subject: Can you speed this up? I often use ruby to run through one set of files and then look at another and if they match then I delete a file, append them.. whatever. I'm relatively new to ruby so I always want to improve the efficiency of my code. Here is working code that I used to append two files in seperate folders and place them in a finalpost folder. How could I improve my code? Temphome = Dir["P:/project/post/Temphome/*.pdf"] Temprep = Dir["P:/project/post/Temprep/*.pdf"] Temphome.each do |filetemp| Temprep.each do |filerep| filerep = File.basename(filerep) filetemp = File.basename(filetemp) if filerep == filetemp cmd = "P:\\project\\bin\\pdftk.exe P:\\project\\post\\Temphome\\#{filetemp} P:\\project\\post\\Temprep\\#{filetemp} cat output P:\\project\\post\\Finaltal\\#{filetemp}" puts "Appending #{filetemp}" `#{cmd}` else next end end end puts "Finished Appending, the new files are located in P:\\project\\post\\finalpost" -- Posted via http://www.ruby-forum.com/.