This is going to be trick, here I am using FileUtils.mv
method.
path = "/home/itsme/videos"
Dir.open(path).each do |p|
next if File.extname(p) != ".mp4"
filename = File.basename(p, File.extname(p))
newname = filename.upcase + File.extname(p)
FileUtils.mv("#{path}/#{p}", "#{path}/#{newname}")
end
To use FileUtils class method you have to include it by using require fileutils