我有一些数据通过批处理文件从我的sql server数据库以制表符分隔格式导出。如何通过标题为“channel”的批处理脚本和标题下每行的文本“channel1”将文章添加到文件中?
答案 0 :(得分:1)
@echo off
setlocal
set "file_path=F:\scriptests\textsql\Book1.txt"
break>tempfile
rem setlocal enableDelayedExpansion
set "firstline="
for /f "useback tokens=* delims=" %%A in ("%file_path%") do (
if not defined firstline (
rem after %%A the symbol is tab but not space
echo %%A "channel"
set "firstline=."
) else (
rem after %%A the symbol is tab but not space
echo %%A "channel1"
)
)>>tempfile
rem first check created tempfile before uncomment the line bellow
rem move /y tempfile "%file_path%"
endlocal