最终我想从 Report.txt 中读取值(一个逗号分隔的文件,在一行中具有像 1,2,3,4 这样的值)并在 summary.yml 的某些字段中更新这些值(...field10 : var1, field11 :var2,... field25 :var3..) 等。为此,我试图存储 Report.txt 中的值,但未设置变量。任何帮助将不胜感激
@echo off
setlocal enableextensions disabledelayedexpansion
rem E:\Backups\ code \ Hazard \ test1 \ it0 ... itn
rem ^root ^ %%X ^ %%Y ^ %%~dpc
for /D %%X in ("*") do for /D %%Y in ("%%~fX\*") do for /f "tokens=1,2,*" %%a in ('
robocopy "%%~fY." "%%~fY." Report.txt /l /nocopy /is /s /nc /ns /ts /ndl /njh /njs
^| sort /r 2^>nul
^| cmd /q /v /c "(set /p .=&echo(!.!)"
') do (
copy "%%~fY\it0\summary.yml" "%%~dpc."
setlocal enabledelayedexpansion
set vidx=0
for /F "tokens=1-4 delims=," %%A in (%%~dpc\Report.txt) do (
set "var1=%%A"
set "var2=%%B"
set "var3=%%C"
set "var4=%%D"
)
set var
@echo !var1!> %%~dpc\temp.txt
@echo !var2!>> %%~dpc\temp.txt
@echo !var3!>> %%~dpc\temp.txt
@echo !var4!>> %%~dpc\temp.txt
)