使用批处理文件和 OpenFolderBox 对话框将文件夹的内容从 A 点复制到 B

Copying contents of a folder from point A to B using a batch file and OpenFolderBox dialog

我一直在寻找一些使用 OpenFolderBox 对话框将文件夹从源复制到目标的方法。

我的一个朋友帮我做了。我记得它曾经工作得很好,但现在我不知道为什么它不复制内容。这是他为我写的批处理源:

SET Target=Default Target
FOR /F "tokens=*" %%A IN ('OpenFolderBox.exe /MD ^|^| ECHO Error^& IF ERRORLEVEL 2 ECHO Cancel') DO SET Target=%%A
SET Target

IF "%Target%"=="Cancel" (
exit
)

else

copy c:\source *.* %Target%
explorer  %Target%

这是“打开文件夹框”对话框: http://www.robvanderwoude.com/files/dialogboxes.zip

顺便说一句,我还需要将 OpenFolderBox 的默认启动目录设置为 "c:\" 而不是 "current path"

我想我明白了:

SET Target=Default Target
FOR /F "tokens=*" %%A IN ('OpenFolderBox.exe /MD ^|^| ECHO Error^& IF ERRORLEVEL 2 ECHO Cancel') DO SET Target=%%A
SET Target

IF "%Target%"=="Cancel" (
exit
)

else (

xcopy /s /y "c:\source" "%Target%"
explorer  %Target%
)