标题: 求助:自定义排序问题
[打印本页]
作者: yywd
时间: 2008-5-26 10:41
标题: 求助:自定义排序问题
求助:自定义排序问题
如已有排号000001-000111,输入000111,自动从000112排序
我这样写的,不行啊
set/p a=输入6位已有排号的尾号后回车 :
Setlocal EnableDelayedExpansion
for /f "tokens=1* delims=:" %%i in ('findstr/n .* 0.txt') do (
set num=%a%%%i
set num=!num:~-6!
echo.[!num!]%%j >>1.txt
)
作者: moniuming
时间: 2008-5-26 11:03
看了3楼的,发现自己理解错误,删除!
[
Last edited by moniuming on 2008-5-26 at 11:20 AM ]
作者: bat-zw
时间: 2008-5-26 11:06
@echo off&Setlocal EnableDelayedExpansion
set/p a=输入3位已有排号的尾号后回车 :
for /f "delims=" %%i in (0.txt) do (
set /a a+=1
echo [000!a!] %%i>>1.txt
)
echo 搞定!
pause>nul
[
Last edited by zw19750516 on 2008-5-26 at 11:07 AM ]
作者: yywd
时间: 2008-5-26 11:45
谢谢您的回复,如从010000排就会超出6位了
作者: moniuming
时间: 2008-5-26 11:55
谢谢6楼提醒,改过来了
@echo off
set/p a=输入6位已有排号的尾号后回车 :
set a=1%a%
set /a a+=1
echo %a:~-6%>>1.txt
echo 搞定!
pause>nul
[
Last edited by moniuming on 2008-5-26 at 12:53 PM ]
作者: bat-zw
时间: 2008-5-26 12:07
Quote: |
Originally posted by moniuming at 2008-5-26 11:55:
[code]@echo off&Setlocal EnableDelayedExpansion
set/p a=输入6位已有排号的尾号后回车 :
for /f "delims=" %%i in (0.txt) do (
set a=1%%a
set /a a+=1
echo ... |
|
set a=1%%a应该是set a=1%a%吧。
ps:set a=1%a%有创意,加分!
[
Last edited by zw19750516 on 2008-5-26 at 12:11 PM ]
作者: yywd
时间: 2008-5-26 12:50
Quote: |
Originally posted by moniuming at 2008-5-26 11:55:
[code]@echo off&Setlocal EnableDelayedExpansion
set/p a=输入6位已有排号的尾号后回车 :
for /f "delims=" %%i in (0.txt) do (
set a=1%a%
set /a a+=1
echo ... |
|
谢谢您的回复, 排号只加了一次并全部用了它,如输入000111,则全部用了000112哟
作者: moniuming
时间: 2008-5-26 13:04
Quote: |
谢谢您的回复, 排号只加了一次并全部用了它,如输入000111,则全部用了000112哟 |
|
请问LZ要一直往下排多少呢
作者: yywd
时间: 2008-5-26 13:13
Quote: |
Originally posted by moniuming at 2008-5-26 13:04:
请问LZ要一直往下排多少呢 |
|
无法固定多少,有多少行就往下排多少, 如上例应该是000112,000113
000114........., 您的却全是000112呀
作者: moniuming
时间: 2008-5-26 13:49
试试这个?
@echo off
Setlocal EnableDelayedExpansion
for /f "delims=" %%i in (0.txt) do set a=1%%i
for /f "delims=" %%i in (0.txt) do (
set /a a+=1
>>1.txt echo !a:~-6!
)
pause
[
Last edited by moniuming on 2008-5-26 at 01:58 PM ]
作者: yywd
时间: 2008-5-26 14:15
Quote: |
Originally posted by moniuming at 2008-5-26 13:49:
试试这个?
[code]@echo off
Setlocal EnableDelayedExpansion
for /f "delims=" %%i in (0.txt) do set a=1%%i
for /f "delims=" %%i in (0.txt) do (
set /a a+=1
>> ... |
|
还是不行呀
作者: moniuming
时间: 2008-5-26 14:19
我已经试过成功了呀,把你的0.txt的内容贴出来看看,如果不是一行一串数字的话是不行的
作者: yywd
时间: 2008-5-26 14:48
c:\BJPrinter\CNMwindows\Canon S200SP\private.ini
c:\Documents and Settings\Administrator\Application Data\combobox_u.ini
c:\Documents and Settings\Administrator\Application Data\editplus_u.ini
c:\Documents and Settings\Administrator\Application Data\setting_u.ini
c:\Documents and Settings\Administrator\Application Data\SogouPY\correction.ini
c:\Documents and Settings\Administrator\Application Data\SogouPY\env.ini
c:\Documents and Settings\Administrator\Application Data\SogouPY\MoHuYin.ini
c:\Documents and Settings\Administrator\Application Data\SogouPY\scdlist.ini
c:\Documents and Settings\Administrator\Application Data\SogouPY\Skin\skin.ini
c:\Documents and Settings\Administrator\Local Settings\Temp\Set.ini
c:\Documents and Settings\Administrator\Local Settings\Temp\SogouPinYinUpdate.ini
c:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\sharedaccess.ini
c:\jjbxb\default.ini
c:\jjbxb\spyb.ini
c:\jjbxb\py\config.ini
c:\jjbxb\save\jjt.ini
c:\Program Files\epson\escndv\setup\ES_uninst.ini
c:\Program Files\epson\escndv\setup\setup.ini
...............
作者: 26933062
时间: 2008-5-26 14:53
唉!
又见外星人 !!!
作者: moniuming
时间: 2008-5-26 15:03
知道LZ的意思了,这个应该没问题了吧
@echo off
Setlocal EnableDelayedExpansion
type nul>1.txt
for /f "tokens=1 delims=:" %%i in ('findstr /n .* 0.txt') do set a=100000%%i
for /f "delims=" %%i in (0.txt) do (
set /a a+=1
>>1.txt echo !a:~-6! %%i
)
如果1.txt中原来就有000001-000111等内容,用下面的代码
@echo off
Setlocal EnableDelayedExpansion
set /p a=输入6位已有排号的尾号后回车 :
set b=1%a%
for /f "delims=" %%i in (0.txt) do (
set /a b+=1
>>1.txt echo !b:~-6! %%i
)
[
Last edited by moniuming on 2008-5-26 at 03:35 PM ]
作者: moniuming
时间: 2008-5-26 15:07
Quote: |
Originally posted by 26933062 at 2008-5-26 14:53:
唉!
又见外星人 !!! |
|
确实也是,LZ也是老会员了,如果能一次性把要求表达清楚就不会浪费那么多时间了
作者: yywd
时间: 2008-5-26 15:41
Quote: |
Originally posted by 26933062 at 2008-5-26 14:53:
唉!
又见外星人 !!! |
|
又见外星人 !!! 努力学习中
作者: yywd
时间: 2008-5-26 16:01
set num=%a%%%i
应该是
set /a num=1%a%+%%i