使用XCopy将包含文件夹的文件复制到另一个目录中 [英] Copy Files with Their Folder into another Directory using XCopy

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

问题描述

我想将此文件C:\Majid\File\text.txt复制到D:\Copied(C:\Majid\File\text.txt ---> D:\\ \\ Copied)

Think I want to copy this file C:\Majid\File\text.txt to D:\Copied (C:\Majid\File\text.txt ---> D:\Copied)

我想使用Xcopy将该文件的完整目录复制到D:\Copied,那么我应该有这样---> D :\Copied\Majid\File\text.txt,因为您看到驱动器号被删除,并且所有其他目录在目标目录中创建。

I want to use Xcopy to copy that file with its full directory into D:\Copied, then I should have something like this ---> D:\Copied\Majid\File\text.txt , as you see the drive letter is removed and all of other directory is created in destination directory.

推荐答案

set sourceFolder="C:\test\new folder\text.txt"
set destinationFolder=%sourceFolder:~3,-1%
echo %destinationFolder%

xcopy %sourceFolder%  "D:\xcopied%destinationFolder%"

这样的东西可以工作。删除源的前几个字符(C:),然后添加目标文件夹的字符(D:\ xcopied)。

Something like that could work. Remove the first few characters of the source ("C:"), then add the characters for the destination folder ("D:\xcopied").

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

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