# Moving all files in a folder to another hard drive

**URL:** <https://www.ruby-forum.com/t/moving-all-files-in-a-folder-to-another-hard-drive/146975>\
**Category:** IT\
**Created:** [August 27, 2008, 8:10am UTC](https://www.ruby-forum.com/t/moving-all-files-in-a-folder-to-another-hard-drive/146975 "2008-08-27T08:10:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [August 27, 2008, 8:10am UTC](https://www.ruby-forum.com/t/moving-all-files-in-a-folder-to-another-hard-drive/146975/1 "2008-08-27T08:10:59Z")

</div>

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  
}
