本帖最后由 pcl_test 于 2016-6-29 02:14 编辑
我这个菜鸟写的。
不过文件名会变成 [原文件名]_1.txt
[bat码]:- echo AddFileNametoCol1
- 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 file name to collumn 1
- setlocal enabledelayedexpansion
- for /f %%C in (namelist.txt) do (
- set n=0
- for /f "delims=" %%a in (%%C.txt) do (
- echo %%C,%%a>>%%C_1.txt
- )
- )
- del namelist.txt
- pause
复制代码
|