日志一键排序,可以用批处理写出来吗?
bat吧
全部回复
仅看楼主
level 5
1、时间标签和02 01是包头,把这两个数据除开后按照每29个字符排好就是一个小数据包。
2021年05月16日 10点05分 1
level 5
2、如果输出能将排序后的4-21位删除掉更好@WYPO
2021年05月16日 10点05分 2
2021年05月16日 10点05分
2021年05月16日 10点05分
level 5
文档里面 有很多条这种数据, 我只是提出来其中一条
2021年05月16日 10点05分 4
level 9
是每29个序为一段吗
2021年05月16日 10点05分 5
level 9
防吞符号,保存为bat,读取每一行,再做字符裁减和后方排序对齐
2021年05月16日 10点05分 6
需要把setlocal ENABLEDELAYEDEXPANSION放在ot_file下放for的上面,原因是开启环境变量后会吞路径特殊符号"!"
2021年05月16日 11点05分
level 9
整体包括排除第4-21列的代码
2021年05月16日 11点05分 7
可以发发无无文件不啊[笑眼][笑眼][突然兴奋]
2021年05月16日 11点05分
level 9
@璐村惂鐢ㄦ埛_000076K馃惥 off & cls
set in_file=%userprofile%\desktop\log.txt
set ot_file=%userprofile%\desktop\tmp.txt
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%a in ('type "%in_file%"') do (
set "@_tmp=%%a"
set "@_str=!@_tmp:~0,15!"
set "@_tmp=!@_tmp:~16!"
echo.!@_str!>>"%ot_file%"
set "@_str="
set @_num=0
for %%s in (!@_tmp!) do (
set /a "@_num=!@_num!+1"
if !@_num! lss 4 (
if /i not "!@_str!"=="" (
set "@_str=!@_str! %%s"
) else (
set @_str=%%s
)
)
if !@_num! gtr 21 (
if /i not "!@_str!"=="" (
set "@_str=!@_str! %%s"
) else (
set @_str=%%s
)
)
if !@_num! geq 29 (
echo.!@_str!>>"%ot_file%"
set "@_str="
set @_num=0
)
)
if /i not "!@_str!"=="" (
echo.!@_str!>>"%ot_file%"
set "@_str="
)
)
setlocal DISABLEDELAYEDEXPANSION
源码,bat文件在txt基础上通过"win+R"调出cmd输入 ren c:\file.txt" *.bat 来更改文件后绰名来获得
2021年05月16日 11点05分 8
弄好了要闪退
2021年05月16日 11点05分
弄好了要闪退
2021年05月16日 11点05分
level 5
[email protected]大哥方便发下邮箱不啊 我排序出来运行报错[笑尿]
2021年05月16日 11点05分 9
level 13
这种简单到word都能搞定。。。
2021年05月16日 11点05分 10
level 13
查找替换不会用吗
2021年05月16日 11点05分 11
先排序,在删除 要删除的它每一排不一样
2021年05月16日 11点05分
几千上万行
2021年05月16日 11点05分
@半夜三更吻你 所以说你还是不会用查找替换呗。
2021年05月17日 06点05分
@半夜三更吻你 我还以为几千上万个文件呢
2021年05月17日 06点05分
level 5
打开bat闪退
2021年05月16日 12点05分 12
set /p in_file=[导入文件:_] set /p ot_file=[输出文件:_] 改一下这两条,这是你要自行输入的,不是我指向桌面的文件[喷]
2021年05月16日 12点05分
level 9
没看懂需求说明,也没有发处理前后的实际文件以供参考
2021年05月16日 12点05分 13
level 9
set /p in_file=[导入文件:_]
set /p ot_file=[输出文件:_]
for /f "delims=" %%s in ('echo.%in_file%') do (set in_file=%%~s)
for /f "delims=" %%s in ('echo.%ot_file%') do (set ot_file=%%~s)
把set in_file 和 set ot_file这两条改为上面的四条,我默认是指向桌面文件的"log"和"tmp"
2021年05月16日 12点05分 14
level 9
去除指定列并保持每行29列,对路径做了修改(set in_file 是需要自行改脚本指向文件)
@璐村惂鐢ㄦ埛_000076K馃惥 off & cls
set /p in_file=[导入文件/拖入文件:_]
set /p ot_file=[输出文件/拖入文件:_]
for /f "delims=" %%s in ('echo.%in_file%') do (set in_file=%%~s)
for /f "delims=" %%s in ('echo.%ot_file%') do (set ot_file=%%~s)
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%a in ('type "%in_file%"') do (
set "@_tmp=%%a"
set "@_str=!@_tmp:~0,15!"
set "@_tmp=!@_tmp:~16!"
echo.!@_str!>>"%ot_file%"
set "@_str="
set @_num=0
for %%s in (!@_tmp!) do (
set /a "@_num=!@_num!+1"
if !@_num! lss 4 (
if /i not "!@_str!"=="" (
set "@_str=!@_str! %%s"
) else (
set @_str=%%s
)
)
if !@_num! gtr 21 (
if /i not "!@_str!"=="" (
set "@_str=!@_str! %%s"
) else (
set @_str=%%s
)
)
if !@_num! geq 29 set @_num=0
)
echo.!@_str!
set "@_tmp=!@_str!"
set "@_str="
set @_num=0
for %%s in (!@_tmp!) do (
set /a "@_num=!@_num!+1"
if /i not "!@_str!"=="" (
set "@_str=!@_str! %%s"
) else (
set @_str=%%s
)
if !@_num! geq 29 (
echo.!@_str!>>"%ot_file%"
set "@_str="
set @_num=0
)
)
if /i not "!@_str!"=="" (
echo.!@_str!>>"%ot_file%"
set "@_str="
)
)
setlocal DISABLEDELAYEDEXPANSION
if /i not EXIST "%in_file%" echo.^<!^> 导入的文件不存在
if /i not EXIST "%ot_file%" echo.^<!^> 输出的文件不存在
set /p=^</^> 处理完毕
2021年05月16日 12点05分 16
独立的"echo.!@_str!"删掉,没用,输出显示会影响速度
2021年05月16日 12点05分
回复 WyPo🍺 :老哥看看你qq
2021年05月20日 07点05分
@WyPo🍺 在吗在吗
2021年05月20日 13点05分
@半夜三更吻你 直接贴吧,qq基本一年才上1到2次,有时连续几年都没上
2021年05月21日 00点05分
1