But I also need a way to rename them incase there are conflicts.
Like if exists? then file.name = "1-"+file.name
or something like that
But I also need a way to rename them incase there are conflicts.
Like if exists? then file.name = "1-"+file.name
or something like that
Hello,
Maybe something like this works for you:
origin = '/test_dir'
destination = '/another_test_dir'
Dir.glob(File.join(origin, '*')).each do |file|
if File.exists?(file)
File.move file, File.join(destination, "1-#{File.basename(file)}")
else
File.move file, File.join(destination, File.basename(file))
end
end
I didn't test this code, so let me know if it worked for you. If not we can iterate over it ;)
Best regards.