I'm looking to move certain .txt files from one directory to another, that I'm creating on the fly containing version numbers and date/time stored as variables:
require 'fileutils'
version = '2.1.6.0'
time = Time.now.strftime("%Y%m%d%H%M%S")
dir = FileUtils.makedirs ("ruby/bar/#{version}/#{time}")
FileUtils.mv 'foo.txt', dir
The directory is created successfully, however a no implicit conversion of Array into String
error is returned for the moving file part.
I tried to modify the code by adding:
dir = dir.to_s
but No such file or directory - (timings.txt, ["ruby/bar/2.1.6.0/20141007183424"])
is returned.
Do I need to convert it to a string? Or is not even possible to move a file to a path saved as a variable?