Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

FileUtils#move

move(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)

Alias of #mv

Moves file(s) src to dest. If file and dest exist on the different disk partition, the file is copied then the original file is removed.

Example
FileUtils.mv 'badname.rb', 'goodname.rb'
FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true  # no error

FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
See also #mv .move #mkpath #mkdir_p also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1