Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 使用Dir.glob从目录中收集文件,现在我想将它们全部移动到一个文件夹中。怎么用?_File_Move_Glob - Fatal编程技术网

File 使用Dir.glob从目录中收集文件,现在我想将它们全部移动到一个文件夹中。怎么用?

File 使用Dir.glob从目录中收集文件,现在我想将它们全部移动到一个文件夹中。怎么用?,file,move,glob,File,Move,Glob,现在我想将它们移动到桌面上一个名为“target_folder”的文件夹中,我该怎么做 我尝试了这个方法,但它返回了“未定义的局部变量或main:Object(namererror)的方法`fileutils'” 这是我学习Ruby第三周的开始,也是我的第一个项目。如果这个问题看起来很简单,我很抱歉。再次感谢。试试这个: require 'fileutils' docx_files.each do |x| fileutils.mv Dir( 'x', '/Users

现在我想将它们移动到桌面上一个名为“target_folder”的文件夹中,我该怎么做

我尝试了这个方法,但它返回了“未定义的局部变量或main:Object(namererror)的方法`fileutils'”

这是我学习Ruby第三周的开始,也是我的第一个项目。如果这个问题看起来很简单,我很抱歉。再次感谢。

试试这个:

    require 'fileutils'

    docx_files.each do |x|
      fileutils.mv Dir( 'x', '/Users/desktop/jorgeolivero/target_folder' )
    end
    require 'fileutils'

    docx_files.each do |x|
      fileutils.mv Dir( 'x', '/Users/desktop/jorgeolivero/target_folder' )
    end
require 'fileutils'

docx_files.each do |x|
    FileUtils.mv x, "/Users/desktop/jorgeolivero/target_folder"
end