Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.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
Batch file 批处理文件。将用户配置文件复制到闪存驱动器_Batch File - Fatal编程技术网

Batch file 批处理文件。将用户配置文件复制到闪存驱动器

Batch file 批处理文件。将用户配置文件复制到闪存驱动器,batch-file,Batch File,我正在尝试编写一个批处理文件,使我们的业务流程自动化。我们租电脑。我们正在尝试在thumb驱动器上编写批处理文件。我们想插入拇指驱动器并复制用户的文档、收藏夹、图片等。我已经成功地编写了命名文件和创建子文件夹的代码。然而,我在复制文件方面做得不够 这是我的密码,谢谢你的帮助 SET initDir=D:\ SET newDir= SET /P newDir=Type folder name: %=% IF DEFINED newDir ( MD D:\%newDir% SET

我正在尝试编写一个批处理文件,使我们的业务流程自动化。我们租电脑。我们正在尝试在thumb驱动器上编写批处理文件。我们想插入拇指驱动器并复制用户的文档、收藏夹、图片等。我已经成功地编写了命名文件和创建子文件夹的代码。然而,我在复制文件方面做得不够

这是我的密码,谢谢你的帮助

SET initDir=D:\
SET newDir=
SET /P newDir=Type folder name: %=%

IF DEFINED newDir (
    MD D:\%newDir%
    SET initDir=%initDir%\%newDir%
)

MD "D:\%newDir%\Desktop"
MD "D:\%newDir%\Documents"
MD "D:\%newDir%\Music"
MD "D:\%newDir%\Pictures"
MD "D:\%newDir%\Favorites"
MD "D:\%newDir%\Links"

copy "C:\Users\%userprofile%\Pictures\" * "D:\%newDir%\Pictures"

xcopy.exe是这里的解决方案。它内置在Windows中

xcopy /s  c:\Folder1 d:\Folder2
您可以在以下位置找到更多选项:

更新: 要将所有文件和子目录(包括任何空子目录)从驱动器A复制到驱动器B,请键入:

xcopy /s /e c:\Folder1 d:\Folder2

谢谢你的回复。我有它复制一些文件,但不是所有的文件现在。现在它正在复制文件夹,它不会创建一些位于代码段中的子文件夹,这些子文件夹位于backupfull initDir=D:\SET newDir=SET/P newDir=Type文件夹名称:%%=%IF DEFINED newDir MD D:\%newDir%SET initDir=%initDir%\%newDir%MD D:\%newDir%\Desktop MD D:\%newDir%\Documents MD D:\%newDir%\Music MD D:\%newDir%\Pictures MD D:\%newDir%\Favorites MDD:\%newDir%\Links Echo复制集backupcmd=xcopy/c xcopy/c%USERPROFILE%\Desktop D:\%newDir%\Desktop%backupcmd%%USERPROFILE%\Documents D:\%newDir%\Documents%backupcmd%%USERPROFILE%\Music%backupcmd%%USERPROFILE%\Pictures D:\%newDir%\Pictures这将帮助您复制所有文件和子目录包括从驱动器A到驱动器B的任何空子目录,键入:xcopy A:B:/s/eGot it。非常感谢。