skyflykyo 当前离线
列兵
@echo off :begin CALL readconfig ITEM1 ITEM1_VALUE CALL readconfig ITEM2 ITEM2_VALUE echo %ITEM1_VALUE% echo %ITEM2_VALUE% cd %ITEM1_VALUE% if exist *(%ITEM2_VALUE%)* copy *(%ITEM2_VALUE%)* C:\aa pause复制代码
评分人数
readconfig.bat: CALL :readconfig %1 %2 :readconfig for /f "skip=1 tokens=1,2 delims==" %%a IN (jvz.ini) Do if %1==%%a set %2=%%b & @echo readconfig get %%a, value is %%b goto :eof jnz.ini [Common] ITEM1=C:\bb ITEM2=2206复制代码
TOP
DAIC 当前离线
中将
另外如果该脚本在C盘运行,%ITEM1_VALUE%的值是在D盘的话,cd %ITEM1_VALUE%这条命令无效。这是为什么呢?
回家路上 当前离线
少尉
for /f "delims=" %%i in ('dir /a-d /b "*%ITEM2_VALUE%*" "%ITEM1_VALUE%"') do copy /y "%%~fi" "C:\aa\"复制代码
cd /d "其他盘符路径"复制代码
@echo off CALL readconfig ITEM1 ITEM1_VALUE CALL readconfig ITEM2 ITEM2_VALUE echo +++++++%ITEM1_VALUE%+++++++ echo +++++++%ITEM2_VALUE%+++++++ cd /d "%ITEM1_VALUE%" echo ------- dir 1 ------- dir /b /a-d echo ------- dir 2 ------- dir /b /a-d "*%ITEM2_VALUE%*" for /f "delims=" %%i in ('dir /a-d /b "*%ITEM2_VALUE%*"') do ( echo copy /y "%%~fi" "C:\aa\" copy /y "%%~fi" "C:\aa\" ) pause复制代码
@echo off for /f "skip=1 tokens=1,2 delims==" %%a in (jvz.ini) do ( if %1==%%a ( set "%2=%%b" echo readconfig get %%a, value is %%b ) )复制代码