David Masover
8/22/2008 4:04:00 AM
On Thursday 21 August 2008 11:35:04 Michael Morin wrote:
> files = Dir.glob('*')
> FileUtils.mkdir 'backup'
> FileUtils.cp_r files, 'backup'
>
> This avoids cp_r trying to descend into the folder it's copying into.
Well, only if "backup" doesn't already exist. Maybe:
files = Dir.glob('*') - ['backup']
FileUtils.mkdir 'backup' unless Dir.exists? 'backup'
FileUtils.cp_r files, 'backup'