S
Stuart Clarke
Hi all,
I have a quick query. I am copying data from a hard drive into a folder
structure, however some of files have the same name and
therefore get overwritten by the most recent file with that name. I have
been using file.identical to establish if the files match and if they do
rename them with an incremental
number (file[1].txt, file[2].txt etc).
This is my identical code
if File.identical?(file, file)
dsFile = File.copy(file, '\\Test')
File.rename(dsFile, "#{fileBase}#{x}.#{ext}")
else
File.copy(file, '\\Test')
end
This renames the file prior to copying, which is not what I want. I
basically want to copy files, if a file with the same name exists rename
it.
Many thanks
Stuart
I have a quick query. I am copying data from a hard drive into a folder
structure, however some of files have the same name and
therefore get overwritten by the most recent file with that name. I have
been using file.identical to establish if the files match and if they do
rename them with an incremental
number (file[1].txt, file[2].txt etc).
This is my identical code
if File.identical?(file, file)
dsFile = File.copy(file, '\\Test')
File.rename(dsFile, "#{fileBase}#{x}.#{ext}")
else
File.copy(file, '\\Test')
end
This renames the file prior to copying, which is not what I want. I
basically want to copy files, if a file with the same name exists rename
it.
Many thanks
Stuart