将文件夹复制到另一个文件夹 [英] Copy folder into another folder

查看:126
本文介绍了将文件夹复制到另一个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个目录复制到另一个目录,使用Perl解释器运行命令(不使用Perl执行复制)

I want to copy one directory into another, running the command with Perl interpreter (not using Perl to perform the copy)

我尝试过:

my $do = "xcopy /E \"D:\/folder1\" \"D:\/folder2\"";
system($do);

但是它只复制 folder1 中的文件到文件夹 folder2
如何将整个 folder2 复制到 folder1


预期结构为:

But it copies only the files inside folder1 to the folder folder2. How can I make it to copy the whole folder2 to folder1.
The expected structure would be :

folder2
  | folder1
  |   |   other_files

不想在Perl中这样做

推荐答案

更改行以将 / I 选项添加到 xcopy 并将目标folder1添加到第二个参数:

change you line to add /I option to xcopy and add the target folder1 to the 2nd argument:

my $do = 'xcopy /E /I "D:/folder1" "D:/folder2/folder1"';

/I: create dirs if don't exist

这篇关于将文件夹复制到另一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆