我正在尝试进行简单的批处理以在文件夹中搜索包含用户提示名称的文件夹,如果找到该文件夹,它将询问是否应将文件夹复制到预定义的位置。当我在 cmd 中单独键入这些行时,它们工作正常,但是当我尝试将其保存在批处理文件中并运行它时,它会在 SET 之后以某种方式关闭 for do 中的某个位置,所以我怀疑它有什么要我的 FOR 在 Notepad++ 中如何格式化?
:START
set /p nw=Please enter the search string:
FOR /f "tokens=*" %%i IN ('dir /a:d-s-h /b ^| findstr /i /m "%nw%"') do (
echo found %%i &&echo.
set /p cflag=Would you like to copy this folder over? Press 'y' and enter:
if %cflag%==y xcopy "%%i" "%sci%" /e
)
set /p rflag=Search for another folder? Press 'y' and enter:
if %rflag%==y goto START
这将在 XP 上运行。
谢谢。