中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-05 20:25
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [原创]******北京身份证号码生成器******* 查看 1,198 回复 4
楼 主 [原创]******北京身份证号码生成器******* 发表于 2007-09-20 15:31 ·  中国 北京 鹏博士BGP
银牌会员
★★★
积分 2,098
发帖 566
注册 2007-09-11 07:27
18年会员
UID 97070
性别 男
状态 离线

@echo off
setlocal enabledelayedexpansion
:::::::::::::::::::::::::::::::::::::BeiJing ID Card No. Creator:::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::: {s11ss 2007-9-20} :::::::::::::::::::::::::::::::::::::
echo Warning:
echo This tool is only used to be technical studying.Please confirm the viewpoint:
echo.
set /p is=I agree with the view.(y/n)
if not %is% equ y (
if not %is% equ Y goto :eof
)
if not exist id.tmp (
set /a n=0
< "%~f0" more +138 >id1.tmp
copy nul id2.tmp >nul
for /f "skip=2 eol= delims=" %%a in (id1.tmp) do (
echo %%a>>id2.tmp
)
del id1.tmp
for /f "delims=" %%a in ('findstr /n .* id2.tmp') do (
set "str=x%%a"
(echo.!str!)>>id.tmp
)
del id2.tmp
)
for /f "delims=" %%a in ('findstr /n .* id.tmp') do (set /a n+=1)
for /f "tokens=1* delims=   " %%a in (id.tmp) do (
set "str=%%a"
set str=!str:~0,-6!
set str=!str:x=!
set str=!str::=.!
echo !str! %%b
)
:add
echo Please choose the direction by inputting the index,like 8:
set /p position=
call :chkchoice %position% add
if !position! gtr !n! call :w index 1 !n! add
if !position! lss 1 call :w index 1 !n! add
for /f "delims=: tokens=1*" %%a in ('findstr "x!position!:" "id.tmp"') do (
set str=%%b
set AddCode=!str:~0,6!
)
goto :birth
:birth
echo Please input the birthday,like 19870307:
set /p BirthCode=
if !BirthCode! gtr 21080101 call :w birthday 18850101 21080101 birth
if !BirthCode! lss 18850101 call :w birthday 18850101 21080101 birth
set m=%BirthCode:~4,2%
if !m! lss 1 call :w month 1 12 birth
if !m! gtr 12 call :w month 1 12 birth
set y=%BirthCode:~0,4%
set d=%BirthCode:~6,2%
set feb=28
set /a r1=!y!%%4
set /a r2=!y!%%100
if %y:~3,1% equ 0 (
if !r1! equ 0 (
if !r2! equ 0 set feb=29
)
) else (
if !r1! equ 0 (
if not !r2! equ 0 set feb=29
)
)
set /a n=1
for %%a in (31,!feb!,31,30,31,30,31,31,30,31,30,31) do (
if !m! equ !n! (
if not !d! leq %%a (
echo Error:In the month !m! of the year !y!,there must be %%a days at most.
goto :birth
)
)
set /a n+=1
)
goto :sex
:sex
echo Please choose the sex by inputting the index,like 1:
echo 1.Male 2.Female
set /p sex=
call :chkchoice %sex% sex
if not !sex! equ 1 (if not !sex! equ 2 (call :w sex 1 2 sex))
:main
set /a s=!sex!%%2
set c1=!AddCode!!BirthCode!
set /a n=0
set /a sum=0
for %%a in (7 9 10 5 8 4 2 1 6 3 7 9 10 5) do (
call set one=%%c1:~!n!,1%%
set /a sum=!sum!+%%a*!one!
set /a n+=1
)
copy nul id.txt >nul
echo.
echo Creating ID card numbers...(several dozens seconds)
for /l %%a in (!s!,2,999) do (
call :seq %%a
set id=!c1!!SeqCode!!CheckCode!
echo !id!>>id.txt
)
echo.
echo 500 ID card numbers have been created successfully in id.txt .
start notepad id.txt
goto :eof
:seq
set SeqCode=%1
if !SeqCode! lss 100 (if !SeqCode! gtr 9 (set SeqCode=0!SeqCode!& goto :check))
if !SeqCode! lss 10 set SeqCode=00!SeqCode!
:check
set /a n=0
set /a sum2=!sum!
for %%a in (8 4 2) do (
call set one=%%SeqCode:~!n!,1%%
set /a sum2=!sum2!+%%a*!one!
set /a n+=1
)
set /a r=!sum2!%%11
set /a n=0
for %%a in (1 0 X 9 8 7 6 5 4 3 2) do (
if !r! equ !n! (set CheckCode=%%a && goto :eof)
set /a n+=1
)
goto :eof
:chkchoice
set str=%1
if not "%str:~1,1%" equ "" (
if "%str:~1,1%" equ "." (
echo . is unnecessary.
echo e.g.:
echo If you would like to choose the second one,inputting 2 is just ok.
goto :%2
)
)
goto :eof
:w
echo Error:The value of %1 is allowed in only. && goto :%4
goto :eof
110000 北京市

110100  市辖区

110101   东城区

110102   西城区

110103   崇文区

110104   宣武区

110105   朝阳区

110106   丰台区

110107   石景山区

110108   海淀区

110109   门头沟区

110111   房山区

110112   通州区

110113   顺义区

110114   昌平区

110115   大兴区

110116   怀柔区

110117   平谷区

110200  县

110228   密云县

110229   延庆县


[ Last edited by s11ss on 2007-9-20 at 04:25 PM ]
本帖最近评分记录 (共 1 条) 点击查看详情
评分人分数时间
knoppix7 +4 2007-09-20 18:07
2 发表于 2007-09-20 15:53 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
积分 3,687
发帖 1,467
注册 2005-08-08 12:00
20年会员
UID 44210
状态 离线
最好能用内容,选中内容后点击,方便复制

TEST
3 发表于 2007-09-20 16:27 ·  中国 北京 鹏博士BGP
银牌会员
★★★
积分 2,098
发帖 566
注册 2007-09-11 07:27
18年会员
UID 97070
性别 男
状态 离线
Originally posted by zh159 at 2007-9-20 03:53 PM:
最好能用内容,选中内容后点击,方便复制

TEST



好用!
4 发表于 2007-09-20 21:29 ·  中国 重庆 电信
版主
★★★★★
积分 9,023
发帖 5,017
注册 2007-05-31 19:39
19年会员
UID 89899
性别 男
状态 离线
倒数第三个是什么县?
5 发表于 2007-09-20 22:12 ·  中国 北京 电信
银牌会员
★★★
积分 2,098
发帖 566
注册 2007-09-11 07:27
18年会员
UID 97070
性别 男
状态 离线
Originally posted by HAT at 2007-9-20 09:29 PM:
倒数第三个是什么县?



这是一个统称,放心,没错.
论坛跳转: