我有一个文件夹结构SQL文件类似如下:连接文本批量
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer1\test.sql
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer2\test.sql
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer3\test.sql
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer4\test.sql
........
我想打一个脚本读取路径(C:\用户\彼得\桌面\ SQL_FILES), 文件名(test.sql)和文本 ,然后连接每个test.sql文件末尾的文本。
请问您能帮我吗?
在此先感谢
:: Hide Command and Set Scope
@echo off
setlocal EnableExtensions
mode 140,50
set /p AbsolutePath="Enter the path of root folder :"
echo.
set /p FileName="Enter the filename with it's extension (ie. test.sql):"
echo.
echo Enter your inserts
echo Press Enter twice when finished
echo (text may not contain ^<, ^>, ^|, ^&, or un-closed quotes)
ver > NUL
set new_line=""
:still_typing
set /p new_line=">"
if errorlevel 1 echo. >> temp.txt & set /p new_line=">"
if errorlevel 1 echo Sending message. . . & goto done_typing
echo %new_line% >> temp.txt
goto still_typing
:done_typing
echo done
:End
endlocal
pause >nul
==================================== =
例如: 例如文件TEST.SQL包含最初:
INSERT INTO TEST(COL1,COL2,COL3) VALUES(3,4,5);
和批量的执行之后假设我添加一个空行,并在文本两个插入物:
INSERT INTO TEST(COL1,COL2,COL3) VALUES(3,4,5);
INSERT INTO TEST(COL1,COL2,COL3) VALUES (1,2,3);
INSERT INTO TEST(COL1,COL2,COL3) VALUES (2,3,4);
请提供您的起始数据示例,以及您希望得到结果的示例。 –
更好的动词是'append'而不是'concatenate',但除了将行附加到'temp.txt'(不初始化文件)之外,没有循环来迭代文件夹/文件,并通过复制或'type test .txt >> test.sql' – LotPings
我修改了最初的问题。谢谢 – prokopis