- @echo &setlocal enabledelayedexpansion
- for /r F:\123 %%i in (*.txt) do (
- set str=%%~ni
- set str1=!str:~,-8!
- set str2=%%i
- for /f "tokens=3 delims=\" %%1 in ("!str2!") do set str2=%%1
-
- if !str1!==onlinetimerecord (
- echo use !str2!^;>456.sql
- echo insert into onlinetimerecord^(PlayerID,AccountID,ClientType,OnlineTime,OfflineTime,LoginIP,DiamondLogin,DiamondLogoff^) values >>456.sql
- for /f "delims=" %%a in ('more %%i') do echo ^(%%a^)^,>>456.sql
- sed -i "$s/,$/;/" 456.sql) else (
-
- if !str1!==gmoperationrecord (
- echo use !str2!^;>456.sql
- echo insert into gmoperation^(OperationTime,Operator,OperationCommand,Target^) values >>456.sql
- for /f "delims=" %%a in ('more %%i') do echo ^(%%a^)^,>>456.sql
- sed -i "$s/,$/;/" 456.sql)
- pause
- )
复制代码
- @echo off
- e:
- cd "Program Files\MySQL\MySQL Server 5.0\bin"
- mysql -u root -p123456 <F:\dsc\20110106\456.sql
复制代码 我运行第一个批处理到暂停处生成一个456.sql文件然后运行第二个批处理,导入数据库正常,所有的文件都能正常导入,但是我把他们和到一起,把第二个分别加到if语句的后面 结果却是只导入的第一个文件的内容,而且是有几个txt文件就导入几次!我想了一天,不得结果,求教高人指点,感激不尽!可能我说的有点不清楚!见谅!还请帮帮忙 |