docx_files = Dir.glob("/Users/jorgeolivero/desktop/*.docx") # Grabbed all of the .docx files on my desktop.
现在我想将它们移到桌面上名为'target_folder'的文件夹中,我该怎么做?
我尝试了这个,但它返回了'undefined局部变量或方法`fileutils'for main:Object(NameError)'
require 'fileutils'
docx_files.each do |x|
fileutils.mv Dir( 'x', '/Users/desktop/jorgeolivero/target_folder' )
end
这是我第三周学习Ruby的开始,这是我的第一个项目。如果这个问题看起来很简单,我道歉。再次感谢。
答案 0 :(得分:0)
试试这个:
require 'fileutils'
docx_files.each do |x|
FileUtils.mv x, "/Users/desktop/jorgeolivero/target_folder"
end