bat批量合并sql文件

1.匹配.sql 的文件

rem 合并SQL脚本
@echo off
set "filename=full.sql"
if exist "%filename%" del "%filename%"
for /r ./ %%f in (*.sql) do (
	if not "%%~nf%%~xf"=="%filename%" (
		echo %%~nf%%~xf
		type %%f>>"%filename%"
		echo. >>"%filename%"
	)
)
echo %filename% 已经被创建

mkdir result
for /r %%a in (full.sql) do move %%a result
pause

2.window已数据命名存在排序进行整体重命名(Set "Num=000000000%%a"&Set "Num=!Num:~-9!")

@Echo Off&SetLocal EnableDelayedExpansion
For /f "delims=" %%a in ('Dir /b /s') Do (
  Set "Str=%%~na"
  For /L %%b in (0,1,9) Do If Defined Str Set "Str=!Str:%%b=!"
  If Not Defined Str Set "Str=<"
  If "%%a" NEQ %0 Call :LP "%%a" "!Str: =!"
)
Exit
:LP
For /F "delims=%~2 " %%a in ("%~n1") Do (
  Set "Num=000000000%%a"&Set "Num=!Num:~-9!"
  For %%b in (!Num!) Do Set "Str=%~nx1"&Ren %1 "!Str:%%a=%%b!"
)

 

你可能感兴趣的:(服务器)