From: Rob Biedenharn Date: 2007-09-27T22:14:07+09:00 Subject: Re: Recursing through directories On Sep 27, 2007, at 8:37 AM, Gabriel Dragffy wrote: > On 26 Sep 2007, at 19:04, Andrea Fazzi wrote: >>> >>> Will this operate recursively? >>> >>> Many thanks >>> >>> Gabriel >> >> Yes. >> >> Dir['/Volumes/**/*'] will match the directories recursively. >> >> Bye. >> Andrea > > Thank you for your help. I have a little trouble getting this > script to operate properly and its given me an error I haven't come > across before... > > Dir['/Volumes/**/*'].each { |file| File.move( file, gsub( /\//, > "-") ) if File.file?( file ) } > TypeError: $_ value need to be String (nil given) > from (irb):4:in `gsub' > from (irb):4 > from (irb):4:in `each' > from (irb):4 > > What might this mean? > > Many thanks > > Gabriel You're not providing a receiver for the gsub() method. Having said that, though, what it seems like you're trying to do is almost certainly a bad idea. It looks like you're prepared to move all files into the current directory. If that's not what you intended, then it's probably very good that you got an error. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com