Moving all files in a folder to another hard drive

This question is actually more related to Ruby itself rather than Rails:
thanks for any info that can help.

I have some code below to move all files in a folder to another hard
drive (which has 2TB of space). It runs well except that whenever a
filename has some international characters, then the line

if File.file?(basedir + file)

will fail. The file is printed as “Chart for ???.xls”

Does someone know how to solve this problem with Ruby being so powerful?
The program is running on Windows. (Vista or XP should both be ok).

code:

require ‘ftools’

basedir = “c:/data/”
target = “w:/data/”

Dir.chdir(basedir)
files = Dir.glob("*");

i = 1
files.each { |file|
p i, file
if File.file?(basedir + file)
puts “Moving…”
File.move(basedir + file, target + file)
puts “Now sleeping…”
sleep(60)
end
i += 1
}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs