且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows批处理文件-嵌套的FOR循环中的变量

更新时间:2022-04-13 03:28:47

@echo off
    setlocal enableextensions disabledelayedexpansion

    for /f %%u in (user.txt) do (
        pushd "C:\Folder\%%u" && (
            for /r %%f in (*) do @xcopy /i /y "%%f" "c:\Folder 2\%%u\" 
            popd
        )
    )

一个简单的解决方案是从第二个for

One simple solution is to remove the first for replaceable parameter from the recurse clause of the second for