batch/bat 一次复制文件夹和内容 [英] batch/bat to copy folder and content at once

查看:17
本文介绍了batch/bat 一次复制文件夹和内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个执行复制的批处理脚本.我想编写脚本来复制整个文件夹.当我想复制单个文件时,我会这样做

I'm writing a batch script that does a copy. I want to script it to copy an entire folder. When I want to copy a single file, I do this

copy %~dp0file.txt file.txt 

如果我有一个具有这种结构的文件夹,是否有一个命令可以一次复制整个文件夹及其内容,同时保留确切的结构.

If I have a folder with this structure, is there a command to copy this entire folder with its contents all at once while preserving the exact structure.

mainfolder/
  file1.txt
  file2.txt
  insidefolder/
     file3.txt
     file4.txt 
     file5.txt

推荐答案

如果你有 xcopy,你可以使用 /E 参数,它会复制目录和子目录以及其中的文件,包括维护空目录的目录结构

if you have xcopy, you can use the /E param, which will copy directories and subdirectories and the files within them, including maintaining the directory structure for empty directories

xcopy [source] [destination] /E

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

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