tags:

views:

78

answers:

1

How can I copy files to a USB stick with Ruby (in Windows)?

So far I have tried to identify the path of the USB stick, with the idea of using FileUtils to copy the files. However, I haven't been able to identify the path.

Anyone know how to do this, or suggest an alternative approach.

Thanks

Edit:

I've found a solution. Windows installed the MP3 player in MTP mode, not flash mode. After a bit of fiddling, I can view and access the device like another.

Found the information from here: http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/cc1e7050-5c44-4eb4-97e7-8edfdb42f24d

+1  A: 

Here's one method that works for me (on Windows XP and Vista) to retrieve the drive letter of connected USB devices:

require 'win32ole'

wmi = WIN32OLE.connect("winmgmts://")

volumes = wmi.ExecQuery("Select DeviceID from Win32_LogicalDisk where DriveType = 2")
volumes.each do |volume|
  puts(volume.DeviceID) 
end
David Mullet
That detects my USB stick, but doesn't recognise the USB MP3 player (and that is without the where clause)
S0rin