Edouard Dantes wrote: > Hi, > > I try to copy files that match a certain pattern to another dir, i write > > cp_r /\/downloads\/bsd/i, "~/biblio/bsd/" > > if i can use regex to do this There's nothing in the standard library docs that suggests you can use a regex for the src argument. The description of cp_r says: --- If src is a directory, this method copies all its contents recursively.... src can be a list of files. --- It doesn't say src can be a regex and that ruby will search your entire hard drive for matching directories. >what is wrong in my approach? > I can't get cp_r to work when providing multiple directories as the source, for example: cp_r(%w{./dir1 ./dir2}, "./test_dir") produces this error: /usr/lib/ruby/1.8/fileutils.rb:475:in `mkdir': No such file or directory - /blah/blah/dir1/test_dir/dir1 (Errno::ENOENT) where dir1 is the current working directory. A solution would be to use Dir.glob() to search your hard drive for matching directories, for instance: arr = Dir.glob("/downloads/bsd", File::FNM_CASEFOLD) and then step through the array using each(), and then call cp_r() on each directory. -- Posted via http://www.ruby-forum.com/.