本帖最后由 pcl_test 于 2016-6-29 12:42 编辑
关于格式1:
我只能作到,没有小数点的部分。
还请其他高手指点。
[c39_temp1.txt]
c39 1
1 0.24
2 14.6
3 0.59
...
[Dat代码]:- @echo off
- echo ---------------------------------
- echo Format one
- echo ---------------------------------
- :: Step1, Catch all txt file and save to namelist.txt
- if exist namelist.txt del namelist.txt
- if exist namelist.lst del namelist.lst
- for %%i in (*.txt) do echo %%i>>namelist.lst
- cd.>namelist.txt
- for /f "tokens=1,2 delims=." %%J in (namelist.lst) do echo %%J >>namelist.txt
- del namelist.lst
-
- :: Step2, add number to collumn 1
- setlocal enabledelayedexpansion
- for /f %%C in (namelist.txt) do (
- set n=0
- for /f "delims=" %%a in (%%C.txt) do (
- set /a n=n+1
- if "!n!"==""1"" cd.>%%C_temp.txt else (
- echo !n! %%a>>%%C_temp.txt
- )
- )
- )
-
- :: Step3, add file name to row1
- for /f %%C in (namelist.txt) do (
- for /f "tokens=1,2 delims= " %%d in (%%C_temp.txt) do (
- if "%%d"=="1" echo %%C 1 >>%%C_temp1.txt
- echo %%d %%e >>%%C_temp1.txt
- )
- )
- del namelist.txt
- del *temp.txt
- pause
复制代码
|