以下字符串位于somefile.txt
:
"8280a263dd758fdaf8a21f1a2d0936ff *File 1.0.exe"
我想将其拆分为2个文件md5sum.txt
和app.txt
。 md5sum.txt
应包含"8280a263dd758fdaf8a21f1a2d0936ff"
,app.txt
应包含"File 1.0.exe"
。
最简单的win cmd批处理脚本是什么?
答案 0 :(得分:1)
@echo off
for /f "tokens=1* delims=* " %%A in (somefile.txt) do (
>md5sum.txt set /p "=%%A"
>app.txt set /p "=%%B"
) <nul
编辑以响应评论中的其他要求
如果可以在apptype.txt中存储“.exe”而不是“exe”,那么
@echo off
for /f "tokens=1* delims=* " %%A in (somefile.txt) do (
>md5sum.txt set /p "=%%A"
>appname.txt set /p "=%%~nB"
>appType.txt set /p "=%%~xB"
) <nul
如果必须删除前导点,则
@echo off
for /f "tokens=1* delims=* " %%A in (somefile.txt) do (
>md5sum.txt set /p "=%%A"
>appname.txt set /p "=%%~nB"
set "apptype=%%~xB"
) <nul
>apptype.txt set /p "%%apptype:~1%%"