回复 16# xslxslxsl
试试- @echo off & cd /d "%~dp0"
- setlocal enabledelayedexpansion
- REM 输入输出文件
- set "in_txt=info.txt"
- set "out_txt=out.txt"
- (
- for /f "usebackq skip=1 tokens=1-3 delims=," %%i in ("%in_txt%") do (
- if "!last1!"=="" (
- set "last1=%%i" & set "last2=%%j" & set "last3=%%k"
- ) else (
- if not "!last1!"=="%%i" (
- set "last1=%%i" & set "last2=%%j" & set "last3=%%k"
- ) else (
- if not "!last3!"=="%%k" (
- for /f "delims=" %%a in ('powershell -c "$t=([datetime]'%%j' - [datetime]'!last2!');'{0:00}时{1:00}分{2:00}秒' -f ($t.Hours+$t.Days*24^),$t.Minutes,$t.Seconds"') do echo %%i,%%a,!last3!
- set "last1=%%i" & set "last2=%%j" & set "last3=%%k"
- )
- )
- )
- )
- )>"%out_txt%"
- pause&exit
复制代码
|