本帖最后由 52hz 于 2024-4-12 13:39 编辑
请教大佬们,我用for /f循环来拆解文本,变量%%b和%%c原本是图片链接,由于开启了变量延迟,拆解后的文本丢失了!!导致链接错误。
为了测试丢失的原因,关闭了变量延迟后链接中的!!就不会丢失了,可是此for循环中还有其它地方是需要使用延迟变量的,这个不能关闭,请问有其他办法解决么?
文本内容如下:- XTC3082228090 https://img.alicdn.com/imgextra/i2/3301937583/O1CN01BLj6Va25t4JSOGUtv_!!3301937583.jpg https://img.alicdn.com/imgextra/i4/3301937583/O1CN012bQDIE25t4JR0chCt_!!3301937583.png
复制代码 代码如下:- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=:" %%N in ('findstr/n ".*" "%~dp0明细复制在这里.txt"')do set "Total=%%N"
- for /f %%I in ('echo prompt $H ^| cmd') do (
- set "BS=%%I%%I%%I%%I%%I"
- )
-
- for /f "tokens=1-3 delims= " %%a in (%~dp01.txt) do (
- set /a X+=1
- set /p "= %BS% ★ 一共【!Total!】个,正在处理第【!X!】个……"<nul
- curl -s "%%b" > "%~dp0白底/%%a.jpg" -H "User-Agent:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)"
- curl -s "%%c" > "%~dp0透明/%%a.png" -H "User-Agent:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)"
- set /p "=%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%"<nul
- pause
- )
- set /p "=%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%"<nul
- set /p "= %BS% 图片下载完成!任意键返回主菜单! "<nul
- pause > nul
- exit
复制代码
|