Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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 xcopy创建文件夹(拖放)_Batch File_Xcopy - Fatal编程技术网

Batch file xcopy创建文件夹(拖放)

Batch file xcopy创建文件夹(拖放),batch-file,xcopy,Batch File,Xcopy,我正在使用xcopy命令,以便将文件拖放到批处理文件: xcopy /s /i "%~1" "D:\folder1" 当我将folder2放在批处理文件上时,我得到以下结果: D:\folder1\文件 但我想得到这个: D:\folder1\folder2\files 因此,为了创建目录,我必须将folder2复制到一个单独的文件夹中: C:\folder3\folder2 这将在folder1中创建folder2目录。什么开关可以避免将folder2移动到单独的文件夹中 谢谢 要一次拖放多

我正在使用
xcopy
命令,以便将文件拖放到批处理文件:

xcopy /s /i "%~1" "D:\folder1"
当我将
folder2
放在批处理文件上时,我得到以下结果:

D:\folder1\文件

但我想得到这个:

D:\folder1\folder2\files

因此,为了创建目录,我必须将
folder2
复制到一个单独的文件夹中:

C:\folder3\folder2

这将在
folder1
中创建
folder2
目录。什么开关可以避免将
folder2
移动到单独的文件夹中


谢谢

要一次拖放多个文件/文件夹,可以使用此批处理。它测试当前项是否为文件夹,并在必要时创建目标,
shift
s当前参数并循环

:: DropTarget.cmd
@Echo off
Set "Dest=D:\Test\Bed\"
:loop
if "%~1" equ "" Exit /b 0
echo d|findstr "%~a1" >Nul 2>&1 &&  if not exist "%Dest%%~nx1" Md "%Dest%%~nx1"
xcopy /S /I "%~1" "%Dest%%~nx1"
Shift
Goto :loop

为了能够一次拖放多个文件/文件夹,您可以使用此批处理。它测试当前项是否为文件夹,并在必要时创建目标,
shift
s当前参数并循环

:: DropTarget.cmd
@Echo off
Set "Dest=D:\Test\Bed\"
:loop
if "%~1" equ "" Exit /b 0
echo d|findstr "%~a1" >Nul 2>&1 &&  if not exist "%Dest%%~nx1" Md "%Dest%%~nx1"
xcopy /S /I "%~1" "%Dest%%~nx1"
Shift
Goto :loop

你能提供文件夹结构吗?
xcopy/s/i“%~1”D:\folder1\%~nx1”
?你能提供文件夹结构吗?
xcopy/s/i“%~1”D:\folder1\%~nx1“
有什么问题吗?