From: Gordon Thiesfeld Date: 2010-12-13T05:34:24+09:00 Subject: Re: Chdir on Windows - beginner doubt On Sun, Dec 12, 2010 at 1:39 PM, Marcelo S. wrote: > Folks, > > Hi, this is my first post here. Tried to search the forum for a specific > answer, but didn't find it. I'm not a programmer, just a curious. Got > Chris Pine's "Learning to Program", and I'm going through all the > exercises. I'm in the YAML chapter now, and I'm trying to adapt the > picture-renaming exercise. > > Somehow, though, my computer doesn't do the task. I'm not sure if the > problem is in Chdir or in another instruction (or even in the addresses > I gave). > > I use Windows Vista. These are the first two lines, where I use Dir: > > Dir.chdir ('D:\\Fotos') > pic_names=Dir['C:\\Users\\Marcelo\\Pictures\\*.{JPG.jpg}'] > > The double inverted slashes were put after I read something about this > being the way Ruby gets the syntax in Windows. > > It says "Downloading 0 files: " > > And nothing else happens. > > What did I do wrong? Luis beat me to it. ;-) Also, I wouldn't recommend using the {JPG,jpg} . You may get unexpected results. I seem to remember case being a problem in older versions, but more modern versions handle it better. irb(main):002:0> Dir["C:/Users/gthiesfeld/pictures/*.{JPG,jpg}"] => ["C:/Users/gthiesfeld/pictures/shadow.jpg", "C:/Users/gthiesfeld/pictures/shadow.jpg"] irb(main):003:0> Dir["C:\\Users\\gthiesfeld\\pictures\\*.{JPG,jpg}"] => [] irb(main):004:0> Dir["C:\\Users\\gthiesfeld\\pictures\\*.jpg"] => [] irb(main):005:0> Dir["C:/Users/gthiesfeld/pictures/*.jpg"] => ["C:/Users/gthiesfeld/pictures/shadow.jpg"] irb(main):006:0> Dir["C:/Users/gthiesfeld/pictures/*.JPG"] => ["C:/Users/gthiesfeld/pictures/shadow.jpg"] irb(main):016:0> Dir["C:/Users/gthiesfeld/pictures/*.{png,jpg}"] => ["C:/Users/gthiesfeld/pictures/Capture.PNG", "C:/Users/gthiesfeld/pictures/Capture1.PNG", "C:/Users/gthiesfeld/pictures/shadow.jpg"] > > Best, > > Marcelo. > > -- > Posted via http://www.ruby-forum.com/. > >