CODE: [Copy to clipboard]
@echo off
setlocal EnableDelayedExpansion
set m=0 //先生成变量%m%
del temp.ps >nul 2>nul
del cover3.txt >nul 2>nul
for /f "tokens=1,2,3,4,5,6,7" %%a in ('findstr /C:"DeviceRGB" newcover.ps') do set jpg=%%a %%b %%c %%d %%e %%f %%g //先取得需要更改的数据 之所以用N多参数,主要时考虑以后好引用
for /f "tokens=2,3" %%h in ('findstr /C:"setcolorspace" newcover.ps') do call :jpg %%h %%i %jpg% //提取数据,用来计算上一行中需要更改的新数据
for /f "tokens=*" %%t in (newcover.ps) do echo %%t >>temp.ps //把空行过滤(因为echo不写空行的)
for /f "tokens=1 delims=:" %%m in ('findstr /P /N /C:"730 730" temp.ps') do set day=%%m //获取行号
set /a day=%day% - 1
for /f "tokens=*" %%s in ('findstr /v /C:"730 730" temp.ps') do (
if !m![ == %day%[ (call :setp) & (echo %%s >>cover3.txt) else (echo %%s >>cover3.txt)
set /a m=!m! + 1
) //将不含730 730 的行写入新文件(这样全文少一行,就是要改的那一行),到达%day%行号时加一行进去(echo一次写一行)
del temp.ps >nul 2>nul
del newcover.ps >nul 2>nul
rename cover3.txt newcover.ps
echo 封面中的作者照片已经更改
:setp
echo %newdata% >>cover3.txt
goto :eof
:jpg
set /a a=730*%1/%2
set newdata= %3 %4 %5 %a% %7 %8
goto :eof
[