Exercises from Chapter 11
Safer Picture Downloading
Well, since I was asking you to adapt it to your computer, I can’t really show you how to do it. I will show you the program I actually wrote, though.
It’s a bit more complex than the other examples here, partly because it’s a real, working tool.
# For Katy, with love. |
### Download pictures from camera card. |
require 'win32ole' |
STDOUT.sync = true |
Thread.abort_on_exception = true |
Dir.chdir 'C:\Documents and Settings\Chris\Desktop\pictureinbox' |
# Always look here for pics. |
pic_names = Dir['!undated/**/*.{jpg,avi}'] |
thm_names = Dir['!undated/**/*.{thm}' ] |
# Scan for memory cards in the card reader. |
WIN32OLE.new("Scripting.FileSystemObject").Drives.each() do |x| |
#driveType 1 is removable ... |
Get Learn to Program, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.