Rover12421's Blog

The End.

批量修改SQL插入语句

原来SQL语句

1
2
3
4
INSERT INTO `accountinfo` (`account`, `password`, `createtime`, `email`) VALUES
('12345', '0280f50d36974672b0b219b26bc80acd', 1211356568, '1345@12346.com'),
('1234', 'aa39195e2750ea3e73835e0720f7e712', 1223658709, '1345@12346.com'),
('123', '766c6faf741de34a64bd2320d2b04e18', 1223658798, '1345@12346.com');

修改成

1
2
3
4
INSERT INTO `accountinfo` (`account`, `password`, `createtime`, `email`) VALUES
('12345', '0280f5', 1211356568, '1345@12346.com'),
('1234', 'aa39195', 1223658709, '1345@12346.com'),
('123', '766c6faf', 1223658798, '1345@12346.com');

要就密码取加密后的前六位

把下面的文件写到1.txt

 (‘12345’, ‘0280f50d36974672b0b219b26bc80acd’, 1211356568, ‘1345@12346.com’), (‘1234’, ‘aa39195e2750ea3e73835e0720f7e712’, 1223658709, ‘1345@12346.com’), (‘123’, ‘766c6faf741de34a64bd2320d2b04e18’, 1223658798, ‘1345@12346.com’), 

BAT代码如下

1
2
3
setlocal enabledelayedexpansion
for /F "eol= tokens=1,2,3,4 delims=^," %%i in (0.txt) do @echo %%i%%j%%k%%l>>2.txt
for /F "eol= tokens=1,2,3,4 delims= " %%i in (2.txt) do (set vb=%%j & echo %%i!vb:~1,6!^'%%k%%l,>>3.txt)

运行得到3.txt

结果如下

1
2
3
('12345', '0280f50d36974672b0b219b26bc80acd', 1211356568, '1345@12346.com'),
('1234', 'aa39195e2750ea3e73835e0720f7e712', 1223658709, '1345@12346.com'),
('123', '766c6faf741de34a64bd2320d2b04e18', 1223658798, '1345@12346.com'),

 

OK,成功

Comments