hitme批處理集合

2020-04-22 14:21 更新



        此文本文檔由pdf格式轉(zhuǎn)換過來,由于轉(zhuǎn)換的限制,

    代碼可能存在斷行的情況,在使用的過程中請(qǐng)注意檢查。


-----------------------------------------------------------------------------



1. CMD.mdb 


1. 16<=>10  


          欲在cmd下轉(zhuǎn)進(jìn)制,自己搞加減乘除? 喝多了頭疼死,算了 


          偷了把雞,利用ping和set幫忙運(yùn)算了一把 


          hoho,什么都不會(huì),就會(huì)投機(jī),巨人肩膀上一站,技術(shù)在那里? 


          用法: DxH 數(shù)字 


          例如: 


          DxH 1234567 


          DxH 0x1234fd3 


          @echo off 


           if "%1"  "" goto :syntax 


           if "%1"  "/?" goto :syntax 


           :H2D 


          set tmpx=%1 


           if "%tmpx:~0,2%"  "0x" ( 


          for /f "delims=" %%i in ('set /a %1') do ( 


          echo. 


          echo %1 = %%i 


          goto :end 


          ) 


          ) 


           :D2H 


          setlocal ENABLEDELAYEDEXPANSION 


          for /f "tokens=2" %%i in ('ping %1 -n 1 -w 1 ^|find "Pinging"') do ( 


          for /f "tokens=1-4 delims=." %%a in ("%%i") do ( 


          set /a tmp1 = %%a / 16 


          set /a tmp2 = %%a - 16 * !tmp1! 


          set /a tmp3 = %%b / 16 


          set /a tmp4 = %%b - 16 * !tmp3! 


           set /a tmp5 = %%c / 16 


           set /a tmp6 = %%c - 16 * !tmp5! 


           set /a tmp7 = %%d / 16 


           set /a tmp8 = %%d - 16 * !tmp7! 


           for /l %%a in (1,1,8) do ( 


           if !tmp%%a!  10 set tmp%%a=!tmp%%a:10=A! 


           if !tmp%%a!  11 set tmp%%a=!tmp%%a:11=B! 


           if !tmp%%a!  12 set tmp%%a=!tmp%%a:12=C! 


           if !tmp%%a!  13 set tmp%%a=!tmp%%a:13=D! 


           if !tmp%%a!  14 set tmp%%a=!tmp%%a:14=E! 


           if !tmp%%a!  15 set tmp%%a=!tmp%%a:15=F! 


           ) 


           ) 


           ) 


           echo. 


           echo %1 = 0x!tmp1!!tmp2!!tmp3!!tmp4!!tmp5!!tmp6!!tmp7!!tmp8! 


           endlocal 


           :end 


           goto:eof 


           :syntax 


           cls 


           echo. 


           echo.DxH.cmd 16進(jìn)制^<=^>10進(jìn)制 互轉(zhuǎn)腳本. Written by hitme 2005.7.27 


           echo. 


           echo.用法:  DxH 數(shù)字 


           echo. 


           echo.例如:  DxH 1234567 


           echo.       DxH 0x1234fd3 


           DxH.rar 


2. CCF 


          attachment.rar 


3. cmd  


          述求:有一個(gè)party,達(dá)到對(duì)到場人員,隨機(jī)分組玩團(tuán)隊(duì)游戲的目的。。。 


          能夠隨意的輸入姓名,輸入完后,把隨機(jī)分組排列的姓名顯示在屏幕上 


          設(shè)姓名文本為name.txt,一個(gè)名字一行 


          分組規(guī)則為:4人一組 


          思路為:亂編號(hào)+編號(hào)排序=亂序,然后分組 


          隨機(jī)空間大小為10的3次方,幾十人的party應(yīng)該夠了吧 


          準(zhǔn)備好name.txt,保存為xy.cmd運(yùn)行,自定義修改紅色部分 


          @echo off 


          for /f "delims=" %%i in (name.txt) do ( 


          setlocal ENABLEDELAYEDEXPANSION 


          for /l %%a in (1,1,3) do ( 


                   echo %random% >nul 


                   set  m=!m!!random:~-1! 


                    ) 


          echo !m!!:%%i>>tmp.txt 


          endlocal 


          ) 


          setlocal ENABLEDELAYEDEXPANSION 


          set /a num=0 


          set /a linenum=0 


          for /f "delims=" %%i in (tmp.txt) do set /a linenum=!linenum!+1 


          for /f "tokens=1,2* delims=: " %%i in ('sort tmp.txt ^| findstr /n 


          "."') do ( 


          set n=%%k 


          set m=!m!!n! 


          set /a num=!num!+1 


          if !num!  4 ( 


          echo !m!>>tmp1.txt 


          set /a num=0 


          set m=) 


          if "%%i"  "!linenum!" ( 


          if "!m!" neq "" echo !m!>>tmp1.txt) 


          ) 


          endlocal 


          findstr /n "." tmp1.txt>list.txt 


          del tmp*.txt 


          start list.txt 


          xy.rar 


4. cmd 


          cmd下的一些文本處理 


          開頭跑個(gè)題,插播個(gè)廣告,隆重推出,鐺鐺鐺鐺~~~,excel!excel!excel! 


          m$那個(gè)電子表格軟件?提它做什么?這題太跑了吧? 


          做行文本處理!排序,過濾,中間插入,翻個(gè)身,倒個(gè)個(gè),奇偶行交換,抽取 


          1,4,9..行,合并,交叉合并,首行填充奇數(shù)行,等等72變 


          相比xnix shell,各種文本編輯軟件,決不遜色,入門還更容易,幫助文件更 


          為詳盡,實(shí)為居家旅行,殺人越貨的強(qiáng)手貨,沒有概念的趕緊試用。 


          使用時(shí)需要的僅僅是個(gè)思路。思路..思路很重要! 


          言歸正傳,還是cmd,用它做文本處理,只能算是勉為其難,湊合著用吧,常 


         做深呼吸,小心給"憋"著了 


         1.列表多個(gè)文本文件文件名+文件內(nèi)容 


         2.構(gòu)造001.txt 002.txt 999.txt 文本內(nèi)容分別是text001 text002 


         3.構(gòu)造http://..001|002|003../01|02|03.htm序列 


         4.將一堆文本形式的網(wǎng)址單獨(dú)轉(zhuǎn)換成IE收藏夾的快捷方式 


         5.將IE收藏夾導(dǎo)出為CSV格式文檔 


         6.有txt文件all.txt 和 a.txt 里面存放的是文件列表,求出a.txt里面沒有 


         ,而all.txt里有的文件列表 


         7.文本文件中的單詞實(shí)現(xiàn)全文自動(dòng)統(tǒng)計(jì)并排序 


         8.統(tǒng)計(jì)一個(gè)文本文件中某一單詞出現(xiàn)的次數(shù)? 


         9.GB和Maxthon群組轉(zhuǎn)換 


         10.合并2個(gè)字幕文本文件 


         11.snap&compare 多個(gè)html的固定內(nèi)容 


         1.列表多個(gè)文本文件文件名+文件內(nèi)容 


         find /v "" *.txt >list.txt 


         *繼續(xù)觀察自帶命令的有價(jià)值輸出 


         ------------------------------------------------------------ 


         2.構(gòu)造001.txt 002.txt 999.txt 文本內(nèi)容分別是text001 text002 


         for /l %i in (1,1,9) do @echo text00%i >00%i.txt 


         for /l %i in (10,1,99) do @echo text0%i >0%i.txt 


         for /l %i in (100,1,999) do @echo text%i >%i.txt 


         *分段補(bǔ)零 


         ----------------------------------------------------------------- 


         3.構(gòu)造http://..001|002|003../01|02|03.htm文件,以下內(nèi)容保存為.bat文件 


         執(zhí)行 


         代碼: 


         setlocal ENABLEDELAYEDEXPANSION 


         for /l %%i in (1001,1,1162) do for /l %%j in (101,1,112) do @(set 


         s=%%i && set t=%%j && echo ^<td^>^<a 


          rel="external nofollow" target="_blank" ^>!s 


          :~1,3!!t:~1,2!.jpg^</a^>^</td^> >>file.htm) 


          endlocal 


          *嵌套for,兩組變量 


          *00x,0x序號(hào)構(gòu)造,加減高位 ccfer su99原創(chuàng) 


          ------------------------------------------------------------ 


          4.將一堆文本形式的網(wǎng)址單獨(dú)轉(zhuǎn)換成IE收藏夾的快捷方式 


          for /f "tokens=1,2,3 delims=:/" %i in ('findstr /n "." 文本.txt') do 


          echo [InternetShortcut] >>%k_%i.url && echo url=http://%k 


          >>%k_%i.url 


          *沒什么特別的 


          ------------------------------------------------------------ 


          5.將IE收藏夾導(dǎo)出為CSV格式文檔,以下內(nèi)容保存為.bat文件執(zhí)行 


          代碼: 


          for /f "tokens=1,3,4 delims=:" %%i in ('findstr /s "http" *.url') do 


          if %%k neq 0 (echo %%i,http:%%j:%%k >>list.csv) else echo 


         %%i,http:%%j >>list.csv 


          *findstr /s *.*得到文件相對(duì)路徑,利用之 


          ------------------------------------------------------------ 


          6.有txt文件all.txt 和 a.txt 里面存放的是文件列表,求出a.txt里面沒有 


          ,而all.txt里有的文件列表 


          #有txt文件 all.txt 和 a.txt 里面存放的是文件列表,a.txt 是 all.txt 的 


          子集,求出a.txt里面沒有,而all.txt里有的文件列表 


          for /f "delims=" %i in (all.txt) do @findstr /x /c:"%i" a.txt >nul 


          || @findstr /x /c:"%i " b.txt >nul || @echo %i>>b.txt 


          *連續(xù)的||..||應(yīng)用 


          ------------------------------------------------------------ 


          7.文本文件中的單詞實(shí)現(xiàn)全文自動(dòng)統(tǒng)計(jì)并排序 


          一個(gè)文本文件,每行有一個(gè)單詞或字符串(有重復(fù)的),幾千行。用word或 


          UE只能做到按字典順序重新排列、或選中某詞統(tǒng)計(jì)其個(gè)數(shù)。 


          有沒有一種方法能自動(dòng)統(tǒng)計(jì)每一不同單詞的出現(xiàn)次數(shù),并輸出結(jié)果列表(加按 


          出現(xiàn)次數(shù)排序就更好了)。 


          源文件內(nèi)容: 


          abc 


          adfg 


          aew 


          dew 


          abc 


          abc 


          aew 


          adfg 


          abc 


          dew 


          adfg 


          ewq 


          abc 


          自動(dòng)統(tǒng)計(jì)并排序后輸出列表(假設(shè)): 


          abc    5 


          adfg    3 


          aew    2 


          dew    2 


          ewq    1 


          設(shè)輸入文本為tmp 


          for /f "delims=" %i in (tmp) do @echo %i >> %i.txt 


          @findstr /n "." *.txt >tmp1 


          for /f "tokens=1-3 delims=:" %i in (tmp1) do @echo %k %j>%i 


          copy *.txt result.txt 


          *分類匯總,excel,awk。。不合用的時(shí)候,cmd頂住 


          *行號(hào)=數(shù)量 


          ------------------------------------------------------------ 


          8.統(tǒng)計(jì)一個(gè)文本文件中某一單詞出現(xiàn)的次數(shù)?,以下內(nèi)容保存為.bat文件執(zhí)行 


          find_word.bat 


          代碼: 


           @echo off 


           setlocal ENABLEDELAYEDEXPANSION 


           set /p file=請(qǐng)輸入要查詢的文件名: 


           set /p name=請(qǐng)輸入要查詢的單詞: 


           set /a n=0 


           :loop 


           set /a n=n+1 


           for /f "tokens=%n% delims=,;.()[]{}!? " %%i in (%file%) do if /i %%i 


           equ %name% echo %name% >>%name%.txt 


           if %n% neq 255 (goto loop) else goto end 


           :end 


           for /f "delims=:" %%i in ('findstr /n "." %name%.txt') do set x=%%i 


           echo %name%出現(xiàn)的次數(shù)為:%x% 


           del %name%.txt 


           endlocal 


          *for進(jìn)行單詞匹配,慢死人的那種,純屬yy 


          ------------------------------------------------------------ 


           9.GB和Maxthon群組轉(zhuǎn)換,以下內(nèi)容保存為.bat文件執(zhí)行 


          GB和Maxthon群組轉(zhuǎn).bat 


          代碼: 


           @echo off 


           :common 


           setlocal ENABLEDELAYEDEXPANSION 


           findstr "CaptorGroup" *.cgp  && goto max_gb ||  goto gb_max 


           :max_gb 


          rd /s/q gb_group 


          md gb_group 


           for %%i in (*.cgp) do echo [Group]>>gb_group\\%%i 


           for %%a in (*.cgp) do for /f "tokens=1-4 delims  :" %%i in ('findstr 


          /n "=" "%%a                " ') do set /a n=%%i-2 && echo 


          name!n!=%%j>>gb_group\%%a && echo ^url!n!=%%k:%%l>>gb_group\%%a 


          goto end 


           :gb_max 


          rd /s/q max_group 


          md max_group 


          for %%a in (*.cgp) do for /f "tokens=2 delims  " %%i in ('findstr 


          "." "%%a               " ') do echo %%i>>max_group\%%~na.txt 


          for %%a in (max_group\*.txt) do echo 


           [CaptorGroup]>>max_group\%%~na.cgp 


          for %%a in (max_group\*.txt) do for /f "tokens=1,2 delims=: " %%i in 


           ('findstr "." "%%a               " ') do if "%%i" neq "http" (set 


          n=%%i) else (if "%%i"    "http" echo 


           !n!=http:%%j>>max_group\%%~na.cgp) 


          del /q max_group\*.txt 


          goto end 


          endlocal 


           :end 


          cls 


          echo 轉(zhuǎn)換完成,請(qǐng)查看子目錄 


          pause 


          exit 


          *兩行并一行,一行拆兩行 


          ------------------------------------------------------------ 


           10.合并2個(gè)字幕文本文件 


          合并2個(gè)字幕文本文件 


          原始文件1如下 


          代碼: 


           1 


          00:00:17,920 --> 00:00:18,625 


          Charlie? 


          2 


          00:00:19,858 --> 00:00:20,606 


          Charlie? 


          3 


            00:00:21,635 --> 00:00:23,140 


            和我一塊兒去散步怎樣? 


            4 


            00:00:23,739 --> 00:00:24,456 


            不 


            5 


            00:00:24,972 --> 00:00:27,317 


            不,不去,Locke,今天我哪兒都不想去 


            原始文件2如下 


            代碼: 


            1 


            00:00:17,820 --> 00:00:18,525 


            Charlie? 


            2 


            00:00:19,758 --> 00:00:20,506 


            Charlie? 


            3 


            00:00:21,535 --> 00:00:23,040 


            How about you and I go for a walk? 


            4 


            00:00:23,639 --> 00:00:24,356 


            No. 


            5 


            00:00:24,872 --> 00:00:27,217 


            No, thanks, Locke. I think I'm gonna stay in today. 


            要求合并后的文件如下 


            代碼: 


            1 


            00:00:17,920 --> 00:00:18,625 


            Charlie? 


            Charlie? 


            2 


          00:00:19,858 --> 00:00:20,606 


          Charlie? 


          Charlie? 


          3 


          00:00:21,635 --> 00:00:23,140 


          和我一塊兒去散步怎樣? 


          How about you and I go for a walk? 


          4 


          00:00:23,739 --> 00:00:24,456 


          不 


         No. 


          5 


          00:00:24,972 --> 00:00:27,317 


          不,不去,Locke,今天我哪兒都不想去 


         No, thanks, Locke. I think I'm gonna stay in today. 


          想把中英文字幕合并起來,邊看片子還可以邊學(xué)學(xué)英文 


          其實(shí)軟件上是可以同時(shí)加載2個(gè)字幕的,也可以實(shí)現(xiàn)要求 


          可是我現(xiàn)在看片子都是在Xbox上看,XBMC這個(gè)播放軟件在同一時(shí)間只能支持一 


          個(gè)srt字幕,所以才會(huì)有此要求 


          設(shè)文件名為file1.txt file2.txt,以下內(nèi)容保存為.bat文件執(zhí)行 


          f.bat 


          代碼: 


          del 1.txt 2.txt all.txt 合并后文檔.txt 


          echo 加一行 >2.txt 


          type file2.txt >>2.txt 


          copy file1.txt 1.txt 


          :#源文件準(zhǔn)備 


          findstr /n "." 1.txt 2.txt >tmp.txt 


          :#合并源文件并添加行號(hào) 


          for /l %%i in (1,1,500) do findstr /r "^1.txt:%%i:" tmp.txt 


          >>all.txt || findstr /r "^2.txt:%%i:" tmp.txt >>all.txt 


          :#分析,構(gòu)造目標(biāo)文件 


         for /f "tokens=3,* delims=:" %%i in (all.txt) do echo %%i%%j >>合并 


         后文檔.txt 


          :#濾除多余信息 


         *交叉合并 


         ------------------------------------------------------------ 


          11.snap&compare 多個(gè)html的固定內(nèi)容 


         有以下內(nèi)容 


         http://www.abcd.com/pub/wrok1.html 


         http://www.abcd.com/pub/wrok2.html 


         http://www.abcd.com/pub/wrok3.html 


         . 


         .. 


         ... 


         http://www.abcd.com/pub/wrok(*).html 


         每個(gè)html,幾乎整個(gè)html部分都是固定內(nèi)容,除了我要監(jiān)測的(文本方式打開 


         )第225行,第38位開始,75位結(jié)束這段,它們 


         有不定時(shí)的改變,所有html更新的部分也許不止這一個(gè)地方,但我只想監(jiān)測這 


         一段 


         有沒有軟件或方法snap一次鏡像,然后下次再snap后作出對(duì)上次snap的對(duì)比 


          ,得出哪個(gè)url的html內(nèi)容監(jiān)測段作出了改變? 


         無錯(cuò)誤控制,以下內(nèi)容保存為.bat文件執(zhí)行 


          snap&compare.bat 


         代碼: 


         @echo off 


         del 差異.txt 2>nul 


         copy /y snap.txt snap_old.txt 1>nul 


          :#清理及悲憤snap 


          :snap 


         echo        %date% %time%       >snap.txt 


          :#加入時(shí)間戳 


          set url=http://www.abcd.com/pub/wrok 


          :#url變量賦值 


          for /l %%i in (1,1,100) do curl %url%%%i.html | findstr /n "." | 


          findstr /r "^225:" >>tmp.txt && echo %url%%%i >>tmp.txt 


          :#下載htm并過濾所需行 


          setlocal ENABLEDELAYEDEXPANSION 


          for /f "tokens=1* delims=:" %%i in (tmp.txt) do if "%%i"  "http" 


          (echo %%i%%j !n! >>snap.txt) else set n=%%j 


          endlocal 


          :#整型快照 


          del tmp.txt 


          :#刪除臨時(shí)文件 


          :goto 


          if not exist snap_old.txt cls && echo           第一次建立快照文件 


          snap^.txt^,請(qǐng)?jiān)俅芜\(yùn)行snap^&compare^.cmd獲取文件差異                       && pause 


          && goto end 


          :#判斷是否存在對(duì)比快照,如不存在則不進(jìn)行差異比較 


          :compare 


          findstr /n "." snap.txt >tmp1.txt 


          findstr /n "." snap_old.txt >tmp2.txt 


          :#為snap文本加入行號(hào) 


          for /l %%i in (2,1,100) do findstr /r "^%%i:" tmp1.txt tmp2.txt 


          >>tmp3.txt 


          :#以行號(hào)為序合并tmp文件 


          findstr /r "1:" tmp*.txt >>差異.txt 


          :#添加時(shí)間戳 


          setlocal ENABLEDELAYEDEXPANSION 


          for /f "tokens=1* delims=:" %%i in (tmp3.txt) do if %%i  tmp1.txt 


          (set n=%%j) else (if %%j neq !n! echo %%j>>差異.txt) 


          endlocal 


          :#比較文本,計(jì)算差異行及行號(hào) 


          del tmp*.txt 


          :#清理臨時(shí)文件 


          cls && echo            完成差異比較,請(qǐng)查看"差異.txt"                         && 


          pause 


          end: 


          *兩行并一行,相似文本比較 


5. cmd 


          cmd下的一些文件處理: 


          1.保持文件夾結(jié)構(gòu),copy特定大小,時(shí)間,類型文件 


          2.保持文件夾結(jié)構(gòu),copy文件名,內(nèi)容空 


          3.按文件數(shù)量移動(dòng)文件到目標(biāo)目錄 


          4.copy某層(3..4..5)子目錄下的文件到目標(biāo)路徑 


          5.刪除文件夾中非某擴(kuò)展名(如txt)的文件 


          6.copy不同文件夾下的同名文件到目標(biāo)文件夾 


          7.同一文件copy到所有子文件夾中 


          8.處理所有擴(kuò)展名為e??且不是exe的文件 


          9.每個(gè)文件生成一個(gè)同名文件夾,然后把各個(gè)文件拷貝到同名文件夾中 


          10.刪除空文件夾 


          1.保持文件夾結(jié)構(gòu),copy特定大小,時(shí)間,類型文件 


          #特定類型 


          xcopy /s/y *.exe 目標(biāo)路徑 


          *很多單獨(dú)的命令(dir;xcopy等)自身就富有變化,善用之 


          #特定大小 


          (例如小于50000字節(jié),具體運(yùn)算符號(hào):EQU - 等于 NEQ - 不等LSS - 小于 LEQ 


         - NEQ - 不等于) 


         for /r %i in (*.*) do if %~zi lss 50000 xcopy /s "%i" 目標(biāo)路徑"%~pi" 


         *出動(dòng)循環(huán)武器for命令,可與眾多命令搭配使用,例如if,findstr,echo等等 


         *這里用它枚舉子文件夾下的文件,%~zi擴(kuò)沖為文件大小,交給if命令進(jìn)行比較 


         運(yùn)算,成功后xcopy至目標(biāo)路徑并copy文件夾 


         *for命令執(zhí)行順序)輸入,for枚舉,do...愛干嗎干嘛 


         #特定時(shí)間 


         例:拷貝特定時(shí)間(2005-04-19)的文件,以下內(nèi)容保存為.bat文件執(zhí)行 


         代碼: 


         setlocal ENABLEDELAYEDEXPANSION 


         for /r %%i in (*.*) do set dd=%%~ti && if "!dd:~0,8!"  "05-04-19" 


         xcopy /s "%%i" 目標(biāo)路徑"%%~pi" 


         endlocal 


         *同上一條,還是for,if,xcopy,由于不能直接對(duì)for變量%~ti進(jìn)行%~ti:~0,8這 


         樣的擴(kuò)展,變通一下,set給普通變量,再做擴(kuò)展 


         *%var~:0,8%擴(kuò)展的說明:兩個(gè)數(shù)字表示偏移量和長度,具體參看set /? 


         *關(guān)于ENABLEDELAYEDEXPANSION延遲環(huán)境變量擴(kuò)充,參看set /?,有實(shí)例說明 


         ----------------------------------------------- 


         2.保持文件夾結(jié)構(gòu),copy文件名,內(nèi)容空 


         xcopy /t/s *.* 目標(biāo)路徑 


         for /r %i in (*.*) do echoc >目標(biāo)路徑"%~pnxi" 


         *xcopy /t/s建立鏡象文件夾,for /r in (*.*)枚舉子文件夾中的文件,利用 


         echoc的bug,寫入0字節(jié)文件 


         ----------------------------------------------- 


         3.按文件數(shù)量移動(dòng)文件到目標(biāo)文件夾,以下內(nèi)容保存為.bat文件執(zhí)行 


         代碼: 


         setlocal ENABLEDELAYEDEXPANSION 


          set /a n=0 


          :loop 


          set /a n=n+1 


          md 文件夾%n% 


          for %%i in (*.*) do move "%%i" 文件夾%n% & dir 文件夾%n% | findstr 


          /c:"100 個(gè)文件" && goto loop 


          endlocal 


          *需求將源文件夾中的文件,每100個(gè)移動(dòng)至文件夾1..2..3 


          *for (*.*) do move一個(gè) && 查找是否有100個(gè)了 && 找到跳出去,移動(dòng)下 


          100個(gè) 


          ----------------------------------------------- 


          4.copy某層(3..4..5)子目錄下的文件到目標(biāo)路徑 


          #復(fù)制第3層文件夾下的文件到目標(biāo)路徑 


          dir /s/b/a:d >d.txt 


          for /f "tokens=1-4 delims=\" %i in (d.txt) do echo n | xcopy /e 


          "%i\%j\%k\%l" 目標(biāo)路徑 


          *dir 列出沒有標(biāo)題信息或摘要的子文件夾,并重定向到d.txt 


          *for /f ..(d.txt),分析d.txt,交xcopy復(fù)制 


          *也可以直接用for /f ..('dir /s/b/a:d') do dir輸出會(huì)被抓進(jìn)內(nèi)存,當(dāng)作 


          文件分析。分兩行寫主要是考慮到文件夾復(fù)雜時(shí)的腳本效率 


          ----------------------------------------------- 


          5.刪除文件夾中非某擴(kuò)展名(如txt)的文件 


          for /f "delims=/" %i in ('dir /b/s *.*') do dir /b/s *.txt | find 


          "%i" || del "%i" 


          *抓dir *.*的輸出,在dir *.txt輸出中查找,沒找到則不是txt文件,刪除之 


          *可擴(kuò)充為非txt+jpg+gif的文件,不會(huì)眼花了 


          ----------------------------------------------- 


          6.copy不同文件夾下的同名文件到目標(biāo)文件夾 


          文件夾1下面有一個(gè)文件123.jpg 


         文件夾2下面也有一個(gè)文件123.jpg,文件名相同,內(nèi)容不同 


         文件夾3下面也有一個(gè)文件123.jpg,文件名相同,內(nèi)容不同 


          …… 


         我想搜索所有的文件123.jpg,copy到一個(gè)目標(biāo)文件夾下,但是我用搜索->復(fù) 


         制,出現(xiàn)后者覆蓋前者的問題,只能保留一個(gè)文件123.jpg,有沒有 


         辦法把這些同名文件拷貝到相同文件夾下?或者是說如何自動(dòng)重命名搜索到的 


         文件? 


         dir /s/b 123.jpg | find /n "123.jpg" >temp.txt 


         for /f "tokens=1,2 delims=[]" %i in (temp.txt) do copy "%j" d:\123- 


         "%i".jpg 


         *枚舉所有123.jpg文件的完整路徑,并加上行號(hào)重定向到temp.txt 


         *for /f () do copy 同時(shí)重命名為123_行號(hào).jpg,行號(hào)不會(huì)重復(fù),利用一下 


         ----------------------------------------------- 


         7.同一文件copy到所有子文件夾中 


         for /r %a in (.) do xcopy /y filename "%~pa" 


         *for /r ..(.) do 只枚舉文件夾 


         ----------------------------------------------- 


         8.處理所有擴(kuò)展名為e??且不是exe的文件 


         for %i in (*.e??) do if /i "%~xi" neq ".exe" echo %i 


         ----------------------------------------------- 


         9.每個(gè)文件生成一個(gè)同名文件夾,然后把各個(gè)文件拷貝到同名文件夾中 


         for %i in (*.*) do md "%~ni" && copy %i "%~ni" 


         ------------------------------------------------ 


          10.刪除空文件夾 


         for /l %a in (1,1,9) do for /r %i in (.) do rd %~si 


6. cmdhtm 


         list.rar 


         1.rar 


7. cmd 


         cmd一些其他應(yīng)用 


         1.快速建用戶和共享文件夾 


         2.讓服務(wù)器在空閑時(shí)自動(dòng)關(guān)機(jī)或休眠 


         3.通過FTP自動(dòng)備份文件 


         4.掃描一個(gè)網(wǎng)段.用for和ping.然后得到存活主機(jī)把結(jié)果存為ip和ip之間用,隔 


         開 


         5.DOS下文件列表按文件名長度遞增排列 


         6.遠(yuǎn)程關(guān)機(jī) 


         1.快速建用戶和共享文件夾 


         又要給學(xué)生機(jī)房裝機(jī)了 


         因?yàn)楝F(xiàn)在有這樣的要求: 


         在教師上加用戶 (A1、A2、……A7、B1……H7)(對(duì)應(yīng)學(xué)生機(jī)) 


         在教師機(jī)上建目錄共享 (要對(duì)應(yīng)機(jī)器.........) 


         就是要建A1目錄給A1那臺(tái)機(jī)用。 


         好繁啊,有什么好的介紹嗎? 


         for %i in (a b c d e f h) do for /l %j in (1,1,7) do echo %i%j 


         >>name.txt 


          :#構(gòu)造序號(hào)文件 


         for /f %i in (name.txt) do net user %i %i /add 


          :#天家用戶 


         for /f %i in (name.txt) do md %i 


          :#建目錄 


         for /f %i in (name.txt) do net share %i=盤符:\%i 


          :#共享目錄 


         for /f %i in (name.txt) do cacls \%i /g %i:f administrator:f 


         :#配置權(quán)限,一路y回車,即可 


         *有for不繁 


         --------------------------------------------------------------- 


         2.讓服務(wù)器在空閑時(shí)自動(dòng)關(guān)機(jī)或休眠 


         單位有一局域網(wǎng),由于win2000的服務(wù)器代理上網(wǎng),內(nèi)網(wǎng)IP:192.168.0.* 


         因大家不定時(shí)上網(wǎng),一般在后半夜便無人再使用網(wǎng)絡(luò),但也不能搞一刀切,不 


         能設(shè)定某個(gè)時(shí)間自動(dòng)關(guān)機(jī),現(xiàn)求一軟件,能自動(dòng)檢測內(nèi)網(wǎng)有無人開機(jī),如果發(fā) 


         現(xiàn)在0點(diǎn)后,半個(gè) 小時(shí)無人上網(wǎng),服務(wù)器則自動(dòng)關(guān)機(jī)(或休眠),我發(fā)現(xiàn) 


         poweroff軟件無法實(shí)現(xiàn)這個(gè)功能。希望大家?guī)兔Α?nbsp;


         run.bat #計(jì)劃任務(wù) 0:30分執(zhí)行這個(gè)bat。每30分鐘重復(fù)執(zhí)行.注意別ping了 


         服務(wù)器,沒測試過,不太可靠 


         以下內(nèi)容保存為.bat文件執(zhí)行 


         代碼: 


         del reply.txt 


         echo 關(guān)機(jī)日志 > reply.txt 


         for /l %%i in (2,1,254) do ping -n 1 192.168.0.%%i | find "Reply" 


         >>reply.txt 


         find "Reply" reply.txt || shutdown 


         --------------------------------------------------------------- 


         3.通過FTP自動(dòng)備份文件 


         機(jī)器 A 


         D:\\aaa\a\ ——》a.rar 


         D:\\bbb\ ————》b.rar 


         每 2個(gè)小時(shí)自動(dòng)生成一個(gè)RAR文件,存放到 D:\\bak\日期\時(shí)間\ 目錄下 


          (D:\\bak\2005-01-04\02.00\)然后自動(dòng)通過FTP傳送到 機(jī)器B(專用備份機(jī) 


         器) 


         請(qǐng)問誰能幫忙寫個(gè)腳本 謝謝。 或者把壓縮過程省略,直接傳送文件夾也可以 


         ?傳送目錄?flashfxp啊 


         以下內(nèi)容保存為.bat文件執(zhí)行 


           代碼: 


           @echo off 


           path=%path%;c:\program files\winrar 


           :rar 


           set tdate=%date:~4,10% 


           set ttime=%time:~0,2% 


           mkdir "d:\bak\%tdate%\%ttime%" 


           rar a -r "d:\bak\%tdate%\%ttime%\a.rar" d:\aaa\*.* 


           rar a -r "d:\bak\%tdate%\%ttime%\b.rar" d:\bbb\*.* 


           :ftp 


           echo open ftp.hitme.com >ftp.txt 


           echo hitme >>ftp.txt 


           echo password >>ftp.txt 


           echo bin >>ftp.txt 


           echo hash >>ftp.txt 


           echo prompt >>ftp.txt 


           echo cd bak >>ftp.txt 


           echo lcd "d:\bak\%tdate%\%ttime%" >>ftp.txt 


           echo mkdir %tdate% >>ftp.txt 


           echo mkdir %tdate%/%ttime% >>ftp.txt 


           echo cd %tdate%/%ttime% >>ftp.txt 


           echo mput *.* >>ftp.txt 


           echo cd /bak >>ftp.txt 


           echo quit >>ftp.txt 


           ftp -s:ftp.txt 


           *echo 構(gòu)造ftp.txt,利用了系統(tǒng)變量%date%,%time%的擴(kuò)充形式 


           --------------------------------------------------------------- 


           4.掃描一個(gè)網(wǎng)段.用for和ping.然后得到存活主機(jī)把結(jié)果存為ip和ip之間用,隔 


           開 


           for /l %i in (1,1,254) do @echo connecting 192.168.1.%i && @(for /f 


          "tokens=1,3 skip=2 delims=: " %j in ('ping 192.168.1.%i') do @if 


          '%j'  'Reply' @find "192.168.1.%i" list.txt > nul 2>nul || @echo 


          %k>>list.txt && @echo 192.168.1.%i connected) 


          *code by su99 


          *單行精品 


          --------------------------------------------------------------- 


          5.DOS下文件列表按文件名長度遞增排列 


          如果一個(gè)目錄里面有如下四個(gè)文件(當(dāng)然,實(shí)際中文件數(shù)量和文件名是隨機(jī)的) 


          1.txt,2.txt,10.txt,20.txt 


          在DOS下要如何使用如何才能讓他們按 


          1.txt 


          2.txt 


          10.txt 


          20.txt 


          輸出,而非 


          1.txt 


          10.txt 


          2.txt 


          20.txt 


          輸出? 


          我用的系統(tǒng)是xp~多謝大家~ 


          for /l %a in (1,1,20) do @(if exist "%a.txt" echo %a.txt) 


          *思路是窮舉。前提是文件名有一定規(guī)律:除了數(shù)字外的部分要一樣,如果是 


          abc1.txt, xyz10.txt這樣亂來,這個(gè)方法就不管用了(嚴(yán)格說,如果是有限 


          個(gè)不同的pattern,仍然可以做到,不過麻煩一些) 


          *code by su99 


                        or 


          list.bat,以下內(nèi)容保存為.bat文件執(zhí)行 


          代碼: 


          @echo off 


          set t=.... 


          :loop 


          set t=%t%. 


          dir /b /a:-d | findstr /r "^%t%$" 


          if "%t%"    "........................." goto end 


          goto loop 


          :end 


          *findstr/r "^.....$過濾排序 


          --------------------------------------------------------------- 


          6.遠(yuǎn)程批量關(guān)機(jī),以下內(nèi)容保存為.bat文件執(zhí)行 


          代碼: 


          for /l %%i in (1,1,254) do @(arp -d & ping 192.168.3.%%i -n 1 -w 100 


          & arp -a | find "00-00-00-00-00-00" > nul || shutdown -m 


          \\192.168.3.%%i -s -f) 


          *關(guān)閉了icmp,照關(guān) 


8. cmd 


          cmd中一些符號(hào)的說明: 


          & 


          最簡單的組合命令,作用是連接n個(gè)命令,按順序執(zhí)行,不管是否有執(zhí)行失敗 


          。 


          a & b 


          #依次執(zhí)行a,b 


          && 


          組合命令,與&命令不同之處在于,判斷是否有執(zhí)行失敗,如失敗將不繼續(xù)執(zhí) 


          行剩下的命令。 


          a && b 


          #a成功,b執(zhí)行 


          || 


          作用與&&相反 


          a || b 


          #a失敗,b執(zhí)行 


          連著用a && b || c,表示a成功,則執(zhí)行b,b失敗,則執(zhí)行c 


          >、>> 


          輸出重定向命令,將命令的輸出寫入到一個(gè)文件中。 


          區(qū)別:>覆蓋寫入,>>尾部追加寫入 


          echo a>a.txt 


          find /v "" *.txt >list.txt 


          | 


          管道命令,前一命令的輸出作為后一命令的輸入,常用于文本過濾操作 


          dir | find "hitme.exe" 


9. cmdUnicode to ASCII 


          TYPE Unicode.txt > ASCII.txt 


10. Curl- 


          CURL? 嗯,說來話長了~~~~ 


          這東西現(xiàn)在已經(jīng)是蘋果機(jī)上內(nèi)置的命令行工具之一了,可見其魅力之一斑 


          1) 


          二話不說,先從這里開始吧! 


          curl http://www.yahoo.com 


          回車之后,www.yahoo.com 的html就稀里嘩啦地顯示在屏幕上了~~~~~ 


          2) 


          嗯,要想把讀過來頁面存下來,是不是要這樣呢? 


          curl http://www.yahoo.com > page.html 


         當(dāng)然可以,但不用這么麻煩的! 


         用curl的內(nèi)置option就好,存下http的結(jié)果,用這個(gè)option: -o 


         curl -o page.html http://www.yahoo.com 


         這樣,你就可以看到屏幕上出現(xiàn)一個(gè)下載頁面進(jìn)度指示。等進(jìn)展到100%,自然 


         就OK咯 


         3) 


         什么什么?!訪問不到?肯定是你的proxy沒有設(shè)定了。 


         使用curl的時(shí)候,用這個(gè)option可以指定http訪問所使用的proxy服務(wù)器及其 


         端口: -x 


         curl -x 123.45.67.89:1080 -o page.html http://www.yahoo.com 


         4) 


         訪問有些網(wǎng)站的時(shí)候比較討厭,他使用cookie來記錄session信息。 


         像IE/NN這樣的瀏覽器,當(dāng)然可以輕易處理cookie信息,但我們的curl呢 


          ?..... 


         我們來學(xué)習(xí)這個(gè)option: -D <-- 這個(gè)是把http的response里面的cookie信息 


         存到一個(gè)特別的文件中去 


         curl -x 123.45.67.89:1080 -o page.html -D cookie0001.txt 


         http://www.yahoo.com 


         這樣,當(dāng)頁面被存到page.html的同時(shí),cookie信息也被存到了 


         cookie0001.txt里面了 


         5) 


         那么,下一次訪問的時(shí)候,如何繼續(xù)使用上次留下的cookie信息呢?要知道 


         ,很多網(wǎng)站都是靠監(jiān)視你的cookie信息, 


         來判斷你是不是不按規(guī)矩訪問他們的網(wǎng)站的。 


         這次我們使用這個(gè)option來把上次的cookie信息追加到http request里面去: 


         -b 


         curl -x 123.45.67.89:1080 -o page1.html -D cookie0002.txt -b 


         cookie0001.txt http://www.yahoo.com 


         這樣,我們就可以幾乎模擬所有的IE操作,去訪問網(wǎng)頁了! 


         6) 


         稍微等等~~~~~我好像忘記什么了~~~~~ 


         對(duì)了!是瀏覽器信息~~~~ 


         有些討厭的網(wǎng)站總要我們使用某些特定的瀏覽器去訪問他們,有時(shí)候更過分的 


         是,還要使用某些特定的版本~~~~ 


         NND,哪里有時(shí)間為了它去找這些怪異的瀏覽器呢??? 


         好在curl給我們提供了一個(gè)有用的option,可以讓我們隨意指定自己這次訪問 


         所宣稱的自己的瀏覽器信息: -A 


         curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 


         123.45.67.89:1080 -o page.html -D cookie0001.txt 


         http://www.yahoo.com 


         這樣,服務(wù)器端接到訪問的要求,會(huì)認(rèn)為你是一個(gè)運(yùn)行在Windows 2000上的 


         IE6.0,嘿嘿嘿,其實(shí)也許你用的是蘋果機(jī)呢! 


         而"Mozilla/4.73 [en] (X11; U; Linux 2.2; 15 i686"則可以告訴對(duì)方你是 


         一臺(tái)PC上跑著的Linux,用的是Netscape 4.73,呵呵呵 


         7) 


         另外一個(gè)服務(wù)器端常用的限制方法,就是檢查http訪問的referer。比如你先 


         訪問首頁,再訪問里面所指定的下載頁,這第二次訪問的referer地址就是第 


         一次訪問成功后的頁面地址。這樣,服務(wù)器端只要發(fā)現(xiàn)對(duì)下載頁面某次訪問的 


         referer地址不 是首頁的地址,就可以斷定那是個(gè)盜連了~~~~~ 


         討厭討厭~~~我就是要盜連~~~~~!! 


         幸好curl給我們提供了設(shè)定referer的option: -e 


         curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 


         123.45.67.89:1080 -e "mail.yahoo.com" -o page.html -D cookie0001.txt 


         http://www.yahoo.com 


         這樣,就可以騙對(duì)方的服務(wù)器,你是從mail.yahoo.com點(diǎn)擊某個(gè)鏈接過來的了 


         ,呵呵呵 


         8) 


         寫著寫著發(fā)現(xiàn)漏掉什么重要的東西了!----- 利用curl 下載文件 


         剛才講過了,下載頁面到一個(gè)文件里,可以使用 -o ,下載文件也是一樣。 


          比如, curl -o 1.jpg http://cgi2.tky.3web.ne.jp/~zzh/screen1.JPG 


         這里教大家一個(gè)新的option: -O 


         大寫的O,這么用: curl -O 


         http://cgi2.tky.3web.ne.jp/~zzh/screen1.JPG 


         這樣,就可以按照服務(wù)器上的文件名,自動(dòng)存在本地了! 


         再來一個(gè)更好用的。 


         如果screen1.JPG以外還有screen2.JPG、screen3.JPG、....、 


         screen10.JPG需要下載,難不成還要讓我們寫一個(gè)script來完成這些操作? 


         不干! 


         在curl里面,這么寫就可以了: 


         curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen[1-10].JPG 


         呵呵呵,厲害吧?!~~~ 


         9) 


         再來,我們繼續(xù)講解下載! 


         curl -O http://cgi2.tky.3web.ne.jp/~{zzh,nick}/[001-201].JPG 


         這樣產(chǎn)生的下載,就是 


         ~zzh/001.JPG 


         ~zzh/002.JPG 


         ... 


         ~zzh/201.JPG 


         ~nick/001.JPG 


         ~nick/002.JPG 


         ... 


         ~nick/201.JPG 


         夠方便的了吧?哈哈哈 


         咦?高興得太早了。 


          由于zzh/nick下的文件名都是001,002...,201,下載下來的文件重名,后面 


         的把前面的文件都給覆蓋掉了~~~ 


         沒關(guān)系,我們還有更狠的! 


         curl -o #2_#1.jpg http://cgi2.tky.3web.ne.jp/~{zzh,nick}/[001- 


         201].JPG 


         --這是.....自定義文件名的下載? 


         --對(duì)頭,呵呵! 


         #1是變量,指的是{zzh,nick}這部分,第一次取值z(mì)zh,第二次取值nick 


         #2代表的變量,則是第二段可變部分---[001-201],取值從001逐一加到201 


         這樣,自定義出來下載下來的文件名,就變成了這樣: 


         原來: ~zzh/001.JPG ---> 下載后: 001-zzh.JPG 


         原來: ~nick/001.JPG ---> 下載后: 001-nick.JPG 


         這樣一來,就不怕文件重名啦,呵呵 


         9) 


         繼續(xù)講下載 


         我們平時(shí)在windows平臺(tái)上,flashget這樣的工具可以幫我們分塊并行下載 


         ,還可以斷線續(xù)傳。 


         curl在這些方面也不輸給誰,嘿嘿 


          比如我們下載screen1.JPG中,突然掉線了,我們就可以這樣開始續(xù)傳 


         curl -c -O http://cgi2.tky.3wb.ne.jp/~zzh/screen1.JPG 


         當(dāng)然,你不要拿個(gè)flashget下載了一半的文件來糊弄我~~~~別的下載軟件的半 


         截文件可不一定能用哦~~~ 


         分塊下載,我們使用這個(gè)option就可以了: -r 


         舉例說明 


          比如我們有一個(gè)http://cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 要下載(趙老 


         師的電話朗誦 :D ) 


         我們就可以用這樣的命令: 


         curl -r 0-10240 -o "zhao.part1" 


         http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\ 


         curl -r 10241-20480 -o "zhao.part1" 


         http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\ 


         curl -r 20481-40960 -o "zhao.part1" 


         http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\ 


         curl -r 40961- -o "zhao.part1" 


         http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 


         這樣就可以分塊下載啦。 


         不過你需要自己把這些破碎的文件合并起來 


          如果你用UNIX或蘋果,用 cat zhao.part* > zhao.mp3就可以 


          如果用的是Windows,用copy /b 來解決吧,呵呵 


          上面講的都是http協(xié)議的下載,其實(shí)ftp也一樣可以用。 


          用法嘛, 


          curl -u name:passwd ftp://ip:port/path/file 


          或者大家熟悉的 


          curl ftp://name:passwd@ip:port/path/file 


          10) 


          說完了下載,接下來自然該講上傳咯 


          上傳的option是 -T 


          比如我們向ftp傳一個(gè)文件: curl -T localfile -u name:passwd 


          ftp://upload_site:port/path/ 


          當(dāng)然,向http服務(wù)器上傳文件也可以 


          比如 curl -T localfile http://cgi2.tky.3web.ne.jp/~zzh/abc.cgi 


          注意,這時(shí)候,使用的協(xié)議是HTTP的PUT method 


          剛才說到PUT,嘿嘿,自然讓老服想起來了其他幾種methos還沒講呢! 


          GET和POST都不能忘哦。 


          http提交一個(gè)表單,比較常用的是POST模式和GET模式 


          GET模式什么option都不用,只需要把變量寫在url里面就可以了 


          比如: 


          curl http://www.yahoo.com/login.cgi?user=nickwolfe&password=12345 


          而POST模式的option則是 -d 


          比如,curl -d "user=nickwolfe&password=12345" 


          http://www.yahoo.com/login.cgi 


          就相當(dāng)于向這個(gè)站點(diǎn)發(fā)出一次登陸申請(qǐng)~~~~~ 


          到底該用GET模式還是POST模式,要看對(duì)面服務(wù)器的程序設(shè)定。 


          一點(diǎn)需要注意的是,POST模式下的文件上的文件上傳,比如 


          <form method="POST" enctype="multipar/form-data" 


          action="http://cgi2.tky.3web.ne.jp/~zzh/up_file.cgi"> 


          <input type=file name=upload> 


          <input type=submit name=nick value="go"> 


          </form> 


          這樣一個(gè)HTTP表單,我們要用curl進(jìn)行模擬,就該是這樣的語法: 


          curl -F upload=@localfile -F nick=go 


          http://cgi2.tky.3web.ne.jp/~zzh/up_file.cgi 


          羅羅嗦嗦講了這么多,其實(shí)curl還有很多很多技巧和用法 


          比如 https的時(shí)候使用本地證書,就可以這樣 


          curl -E localcert.pem https://remote_server 


          再比如,你還可以用curl通過dict協(xié)議去查字典~~~~~ 


          curl dict://dict.org/d:computer 


          今天就先講到這里吧,呵呵。瘋狂的curl功能,需要你---一起來發(fā)掘。 


          copyright by nickwolfe@CCF 


          2004.08.24 21:24應(yīng)朋友之邀所作--初稿 


          curl.rar 


11. MT<->IE cmd 


          快捷組cgp->收藏夾url 


          conv_c_u.cmd 


          MT Groups目錄下運(yùn)行 


          代碼 


          @echo off 


          setlocal ENABLEDELAYEDEXPANSION 


          for %%a in (*.cgp) do ( 


          set pathu=ie_url\%%~na 


          md !pathu! 


           set /a n=0 


           for /f "skip=1 tokens=1* delims  " %%i in (%%a) do ( 


           if "%%i"  "[Properties]" (set /a n=1) else ( 


            if !n!  0 ( 


               echo [InternetShortcut]>>"!pathu!\%%i".url 


              echo URL=%%j>>"!pathu!\%%i".url) 


              ) 


           ) 


           ) 


           endlocal 


           收藏夾url->快捷組cgp 


           conv_u_c.cmd 


           IE_Favorites目錄下運(yùn)行 


           代碼 


           @echo off 


           echo [CaptorGroup]>>url.cgp 


           for /f %%i in ('dir /b/ad') do ( 


           echo [CaptorGroup]>>%%i.cgp 


           ) 


           setlocal ENABLEDELAYEDEXPANSION 


           for /f "usebackq tokens=1,2* delims=\=" %%i in (`findstr /s /r 


           "^URL=" *.url^|findstr "\\"`) do ( 


           set n=%%j 


           echo !n:~0,-8!=%%k>>%%i.cgp 


           ) 


           for /f "usebackq tokens=1* delims=\=" %%i in (`findstr /s /r "^URL=" 


           *.url^|findstr /v "\\"`) do ( 


           set n=%%i 


           echo !n:~0,-8!=%%j>>url.cgp 


           ) 


           endlocal 


           conv_c_u.rar 


           conv_u_c.rar 


12. PingDNS 


           @echo off 


           if [%1]  [] ( 


                       set ip=emptyType 


                       set str=Address 


           ) else ( 


                       set ip=%1 


                       set str=Name 


           )    


           for /f  "tokens=2" %%i in ('nslookup %ip% ^|findstr "%str%"') do 


           ping %2 %3 %%i 


13. ping() 


           試玩一下,test by win2kchs,部分系統(tǒng)注意自行替換紅色部分 


           用法:cmd下 


           sping ip/hostname 


           sping.rar 


14. treehtm 


           進(jìn)入目錄,一層層點(diǎn),嫌煩 


           tree命令只給看看。。不給點(diǎn)。。。我就是要點(diǎn) 


           tree命令的htm版 


           htm,css都沒搞過,現(xiàn)學(xué)的,高手奸笑了 


           根目錄下運(yùn)行,測試,保存為tree_htm.cmd運(yùn)行 


           @echo off 


           del tree.htm 2>nul 


           echo                   tree命令的htm版 


           echo. 


           echo              by hitme 2005.7.3 hitme@xiahaixiao.com 


           echo. 


           echo 可直接點(diǎn)擊進(jìn)入6層內(nèi)目錄,完美主義者請(qǐng)自行修改 


           echo  


           echo. 


           echo 請(qǐng)稍候............. 


            >end.htm echo ^<head^> 


           >>end.htm echo ^<meta http-equiv="Content-Type" content="text/html^; 


           charset=gb2312" ^/^> 


           >>end.htm echo ^<style type="text/css"^> 


           >>end.htm echo ^<!-- 


           >>end.htm echo a:active { text-decoration: none ; color: red ; font- 


           size: 12pt } 


           >>end.htm echo a:visited { text-decoration: none ; color: green ; 


           font-size: 12pt } 


           >>end.htm echo a:link { text-decoration: none ; font-size: 12pt } 


           >>end.htm echo --^> 


           >>end.htm echo ^</style^> 


           >>end.htm echo ^</head^> 


           >>end.htm echo ^<body^> 


           setlocal  ENABLEDELAYEDEXPANSION 


           for /f "skip=2 delims=" %%i in ('tree') do ( 


           set n=%%i 


           if "!n:~1,1!"  ":" set n0=!n:~0,2! 


           if "!n:~1,1!"  "─" (set n1=!n:~2! 


                set n2 


                set n3 


                set n4 


                set n5 


                set n6 


                set n7=) 


                if "!n:~4,1!"  "─" (set n2=!n:~5! 


                set n3 


                set n4 


                set n5 


                set n6 


                set n7=) 


                if "!n:~5,1!"  "─" (set n2=!n:~6! 


                set n3 


                set n4 


                set n5 


                set n6 


                set n7=) 


                if "!n:~7,1!"  "─" (set n3=!n:~8! 


                set n4 


                set n5 


                set n6 


                set n7=) 


                if "!n:~8,1!"  "─" (set n3=!n:~9! 


                set n4 


                set n5 


                set n6 


                set n7=) 


                if "!n:~9,1!"  "─" (set n3=!n:~10! 


                set n4 


                set n5 


                set n6 


                set n7=) 


                if "!n:~10,1!"  "─" (set n4=!n:~11! 


                set n5 


                set n6 


                set n7=) 


           if "!n:~11,1!"  "─" (set n4=!n:~12! 


           set n5 


           set n6 


           set n7=) 


           if "!n:~12,1!"  "─" (set n4=!n:~13! 


           set n5 


           set n6 


           set n7=) 


              if "!n:~13,1!"  "─" (set n5=!n:~14! 


           set n6 


           set n7=) 


           if "!n:~14,1!"  "─" (set n5=!n:~15! 


           set n6 


           set n7=) 


           if "!n:~15,1!"  "─" (set n5=!n:~16! 


           set n6 


           set n7=) 


           if "!n:~16,1!"  "─" (set n5=!n:~17! 


           set n6 


           set n7=) 


           if "!n:~17,1!"  "─" (set n6=!n:~18!) 


           if "!n:~18,1!"  "─" (set n6=!n:~19!) 


           if "!n:~19,1!"  "─" (set n6=!n:~20!) 


           if "!n:~20,1!"  "─" (set n6=!n:~21!) 


           set n=!n: =^&nbsp;! 


           >>end.htm echo ^<a href="!n0!\!n1!\!n2!\!n3!\!n4!\!n5!\!n6!" 


           target="_blank"^>!n!^</a^> 


           >>end.htm echo ^</br^> 


           ) 


           for /f "delims=" %%i in (end.htm) do ( 


           set x=%%i 


                                  for /l %%a in (1,1,5) do ( 


              set x=!x:\\=\! 


           ) 


           echo !x!>>tree.htm 


           ) 


           endlocal 


           del end.htm 


           start tree.htm 


           tree_htm.rar 


15. wget 


           hxxp://www.sergeaura.net/TGP/001/images/01.jpg 


           ... 


           hxxp://www.sergeaura.net/TGP/001/images/12.jpg 


           ...... 


           ...... 


           ...... 


           hxxp://www.sergeaura.net/TGP/162/images/01.jpg 


           ... 


           hxxp://www.sergeaura.net/TGP/162/images/12.jpg 


           curl cmd下運(yùn)行 


           curl -o #1_#2.jpg hxxp://www.sergeaura.net/TGP/[001-162]/images/[01- 


           12].jpg 


           wget+for......九陽神功,內(nèi)功部分稍顯復(fù)雜,打通2脈后,功力日進(jìn)。保存 


           為get.cmd運(yùn)行 


           setlocal ENABLEDELAYEDEXPANSION 


           for /l %%i in (1001,1,1162) do for /l %%j in (101,1,112) do @( 


                                    set s=%%i 


                                    set t=%%j 


                                    wget -O !s:~1,3!!t:~1,2!.jpg 


          hxxp://www.sergeaura.net/TGP/!s:~1,3!/images/!t:~1,2!.jpg) 


          endlocal 


          wget.zip 


16.  


          for /r %I in (*.*) do echo %~fnI >> c:\列表.txt 


          簡單: tree /f 


17. QQ 3 


          1.查看長期沒聯(lián)系的QQ好友,方便刪除 比如3個(gè)月內(nèi)沒和你說話 


          設(shè)導(dǎo)出的混在一起聊天記錄為qq.txt 


          ------------------------------------------- 


          findstr "消息對(duì)象:" qq.txt >聯(lián)系人.txt 


          for /f "tokens=2 delims=()" %i in (聯(lián)系人.txt) do findstr "2004-0[5- 


          7]-" qq.txt ^ | find "%i"|| echo %i >>結(jié)果.txt 


          2.提取msn 聯(lián)系人email列表 方便導(dǎo)入郵件收發(fā)軟件 


          設(shè)導(dǎo)出的文件為msn.ctt,list.csv為結(jié)果 


          for /f "tokens=3 delims=<>" %%i in (msn.ctt) do echo %%i >>list.csv 


          1,導(dǎo)出總談話記錄 


          2,為了最大兼容,把qq.txt拷貝到C盤根目錄 


          3,運(yùn)行 -CMD(XP) 或者 windows 98 進(jìn)入dos 狀態(tài) 


          4,輸入 


          findstr "消息對(duì)象:" qq.txt >聯(lián)系人.txt 


         回車 


         5,輸入 


         for /f "tokens=2 delims=()" %i in (聯(lián)系人.txt) do findstr "2004-0[5- 


         7]-" qq.txt ^ | find "%i"|| echo %i >>結(jié)果.txt 


         回車 


         6,等待 


         引用回復(fù) 


18. 357 


         吃完飯,mm要我給折騰個(gè)35選7的選號(hào)器,去試試運(yùn)氣,我運(yùn)氣很背的,買了 


         5,6w了,基本沒中300以上過,寫的東西不知道背不背 


         思路是: 


         構(gòu)造1-35數(shù)字的文本行,每行一個(gè),同時(shí)加上3位的隨機(jī)數(shù) 


         例如 


         234:1 


         214:2 


         523:3 


         ... 


         然后對(duì)此文本排序,取前7個(gè)數(shù)字,完成 


         年紀(jì)大了,兩瓶啤酒下去,就有點(diǎn)暈了。。。有興趣的試試 


         保存為35x7.cmd運(yùn)行 


         @echo off 


          :start 


         del tmp.txt 2>nul 


         for /l %%i in (1,1,35) do ( 


         setlocal ENABLEDELAYEDEXPANSION 


         for /l %%a in (1,1,3) do ( 


         echo %random% >nul 


         set  m=!m!!random:~-1! 


         ) 


         echo !m!:%%i>>tmp.txt 


           endlocal 


           ) 


           setlocal ENABLEDELAYEDEXPANSION 


           set /a num=0 


           for /f "tokens=2 delims=:" %%i in ('sort tmp.txt') do ( 


           set n=%%i 


           set m=!m! !n! 


           set /a num=!num!+1 


           if !num!  7 echo 本期35選7的中獎(jiǎng)號(hào)碼是: !m:~1! && goto :save 


           ) 


           :save 


           set /p x=保留號(hào)碼至num.txt[y/n] 


           if /i [%x%]  [y] (echo !m:~1!>>num.txt && endlocal && goto :start) 


           else (endlocal && goto :start) 


           35x7.rar 


19.  


           保存為xx.cmd文檔目錄下運(yùn)行,再次運(yùn)行恢復(fù) 


           @echo off 


           setlocal  ENABLEDELAYEDEXPANSION 


           for /f "delims=" %%i in ('dir /s/b *.doc') do ( 


           set n=%%~ni 


           set r_name=%%~ni 


           set t_name 


           for /l %%a in (1,1,100) do ( 


           set n1=!n:~0,1! 


           set n=!n:~1! 


           set t_name=!n1!!t_name! 


           if "!n!"  "" ( 


           cd "%%~dpi" 


           ren  "!r_name!.doc" "!t_name!.doc" 2>nul>nul 


           ) 


           ) 


           ) 


           endlocal 


           xx.rar 


20. htm-----CMD  


           這是基礎(chǔ)了。。。格式簡單,構(gòu)造起來較容易 


           cmd查查也方便 如:help dir 


           有人需要就造個(gè)htm手冊(cè)玩玩 


           保存為cmd_help.cmd運(yùn)行 


           @echo off 


           del net_cmd_help.htm 2>nul 


           echo. 


           echo......請(qǐng)稍候,構(gòu)造htm文件中..... 


           echo. 


           >cmd_help.htm echo ^<head^> 


           >>cmd_help.htm echo ^<title^>Help for Net commands^</title^> 


           >>cmd_help.htm echo ^<meta http-equiv="Content-Type" 


           content="text/html^; charset=gb2312" ^/^> 


           >>cmd_help.htm echo ^</head^> 


           >>cmd_help.htm echo ^<A NAME="Top"^> 


           >>cmd_help.htm echo ^<center^> 


           >>cmd_help.htm echo ^<h1^>CMD 命令速查手冊(cè)^</h1^> 


           >>cmd_help.htm echo Written by Hitme 


           >>cmd_help.htm echo ^</center^> 


           >>cmd_help.htm echo ^<br^> 


           ver|find "Windows XP" && goto:joke 


           for /f "tokens=1*" %%i in ('help^|more +3') do ( 


           help %%i>nul && echo ^<a href="#%%i"^>%%i^</a^>^&nbsp;^&nbsp;%%j 


           >>cmd_help.htm || echo ^&nbsp;^&nbsp;^&nbsp;^&nbsp; %%i 


           %%j>>cmd_help.htm 


           >>cmd_help.htm echo ^</br^> 


           ) 


           for /f  %%i in ('help^|more +3') do ( 


           help %%i>nul && ( 


           >>cmd_help.htm echo ^<a name="%%i"^> 


           >>cmd_help.htm echo ^<h2^>%%i^</h2^> 


           >>cmd_help.htm echo ^<pre^> 


           help %%i>>cmd_help.htm 


           >>cmd_help.htm echo ^</pre^> 


           >>cmd_help.htm echo ^<a href="#top"^>返回頁首^</a^> 


           ) 


           ) 


           start cmd_help.htm 


           goto:eof 


           :joke 


           for /f "tokens=1*" %%i in ('help^|more +1') do ( 


           help %%i>nul && echo ^&nbsp;^&nbsp;^&nbsp;^&nbsp; %%i 


           %%j>>cmd_help.htm || echo ^<a 


           href="#%%i"^>%%i^</a^>^&nbsp;^&nbsp;%%j >>cmd_help.htm 


           >>cmd_help.htm echo ^</br^> 


           ) 


           for /f  %%i in ('help^|more +1') do ( 


           help %%i>nul || ( 


           >>cmd_help.htm echo ^<a name="%%i"^> 


           >>cmd_help.htm echo ^<h2^>%%i^</h2^> 


           >>cmd_help.htm echo ^<pre^> 


           help %%i>>cmd_help.htm 


           >>cmd_help.htm echo ^</pre^> 


           >>cmd_help.htm echo ^<a href="#top"^>返回頁首^</a^> 


           ) 


           ) 


           start cmd_help.htm 


           cmd_help.rar 


21. htm-----Net  


           net /? 


           net view /help 


           查看太煩,倒騰個(gè)手冊(cè)玩玩 


           保存為make.cmd運(yùn)行 


           @echo off 


           del net_help.htm 2>nul 


           echo. 


           echo......請(qǐng)稍候,構(gòu)造htm文件中..... 


           echo. 


           setlocal  ENABLEDELAYEDEXPANSION 


           for /f "tokens=1,2 delims=:" %%i in ('net help^|more +9^|findstr /n 


           "."') do ( 


           set n=%%j 


           if %%i gtr 0 (if %%i lss 10 ( 


           echo !n:~3,22!>>tmp.txt 


           echo !n:~28,14!>>tmp.txt 


           echo !n:~50,14!>>tmp.txt 


           ) 


           ) 


           ) 


           for /f "delims=" %%i in ('sort tmp.txt') do ( 


           set x=%%i 


           set x=!x: =! 


           set x=!x:CONFIGWORKSTATION=CONFIG WORKSTATION! 


           set x=!x:CONFIGSERVER=CONFIG SERVER! 


           set x=!x:NET=NET ! 


           echo !x!>>tmp1.txt 


           ) 


           endlocal 


            >net_help.htm echo ^<head^> 


           >>net_help.htm echo ^<title^>Help for Net commands^</title^> 


           >>net_help.htm echo ^<meta http-equiv="Content-Type" 


           content="text/html^; charset=gb2312" ^/^> 


           >>net_help.htm echo ^</head^> 


           >>net_help.htm echo ^<A NAME="Top"^> 


           >>net_help.htm echo ^<center^> 


           >>net_help.htm echo ^<h1^>Net 命令速查手冊(cè)^</h1^> 


           >>net_help.htm echo Written by Hitme 


           >>net_help.htm echo ^</center^> 


           for /f "delims=" %%i in (tmp1.txt) do ( 


           >>net_help.htm echo ^<a href="#%%i"^>%%i^</a^> 


           >>net_help.htm echo ^</br^> 


           ) 


           for /f "delims=" %%i in (tmp1.txt) do ( 


           >>net_help.htm echo ^<a name="%%i"^> 


           >>net_help.htm echo ^<h2^>%%i^</h2^> 


           >>net_help.htm echo ^<pre^> 


           %%i /help|more /s>>net_help.htm 


           >>net_help.htm echo ^</pre^> 


           >>net_help.htm echo ^<a href="#top"^>返回頁首^</a^> 


           ) 


           del tmp*.txt 


           start net_help.htm 


           net_help.rar 


           make.rar 


22. 297 


           @echo off 


           :start 


           setlocal ENABLEDELAYEDEXPANSION 


           :loop 


           del tmp.txt 2>nul 


           for /l %%i in (1,1,7) do ( 


           echo %random% >nul 


                 set /a m%%i=!random:~-1!+1 


           set /a m%%i=!m%%i!/4 


           set /a m%%i=!m%%i:~0,1! 


           echo %random% >nul 


           set /a n%%i=!random:~-1! 


           if !m%%i!!n%%i!  00 goto:loop 


           findstr /m "!m%%i!!n%%i!" tmp.txt 2>nul >nul && goto :loop 


           echo !m%%i!!n%%i!>>tmp.txt 


           ) 


           endlocal 


           setlocal ENABLEDELAYEDEXPANSION 


           for /f %%i in ('sort tmp.txt') do ( 


           set n=%%i 


           set m=!m! !n! 


           ) 


           del tmp.txt 


           cls 


           echo. 


           echo.¥100000000000000000000000000000000000000000.00 


           echo. 


           echo. Hitme,29選7必中,號(hào)碼是 !m! 


           echo. 


           echo.¥100000000000000000000000000000000000000000.00 


           echo. 


           set /p x=保留號(hào)碼至num.txt[y/n] 


           if /i [%x%]  [y] (echo !m!>>num.txt && endlocal && goto :start) else 


           (endlocal && goto :start) 


           29x7.rar 


23. 6+1 


           @echo off 


           setlocal ENABLEDELAYEDEXPANSION 


           cls 


           del num.txt 2>nul 


           :loop 


           for /l %%i in (1,1,7) do ( 


           echo %random% >nul 


                 set n%%i=!random:~-1! 


           ) 


           set num=%n1%%n2%%n3%%n4%%n5%%n6%%n7% 


           echo. 


           echo.*********************************** 


           echo Hitme,6+1必中,號(hào)碼是%num% 


           echo.*********************************** 


           echo. 


           set /p x=保留號(hào)碼至num.txt[y/n] 


           if /i %x%  y (echo %num%>>num.txt && goto :loop) else (goto :loop) 


           endlocal 


           6+1.rar 


24.  


           @echo off 


            :start 


           setlocal ENABLEDELAYEDEXPANSION 


            :loop_a 


           del tmp*.txt 2>nul 


           for /l %%i in (1,1,6) do ( 


           echo %random% >nul 


           set /a s%%i=!random:~-1! 


           echo %random% >nul 


           set /a g%%i=!random:~-1! 


           if "!s%%i!"  "0" (set /a _VAR_=!g%%i! / 3) else (set /a 


           _VAR_=!s%%i!!g%%i! / 3) 


           if "!_VAR_:~1,1!"  "" set _VAR_=0!_VAR_! 


           findstr /m "!_VAR_!" tmp.txt 2>nul >nul && goto :loop_a 


           if "!_VAR_!"  "00" (echo 33>>tmp.txt) else (echo !_VAR_!>>tmp.txt) 


           ) 


           sort tmp.txt>tmp1.txt 


           endlocal 


            :loop_b 


           setlocal ENABLEDELAYEDEXPANSION 


           echo %random% >nul 


           set /a s=!random:~-1! 


           echo %random% >nul 


           set /a g=!random:~-1! 


           if "!s!"  "0" (set /a _VAR_=!g! / 6) else (set /a _VAR_=!s!!g! / 6) 


           if "!_VAR_:~1,1!"  "" set _VAR_=0!_VAR_! 


           echo ^|>>tmp1.txt 


           if "!_VAR_!"  "00" (echo 16>>tmp1.txt) else (echo !_VAR_!>>tmp1.txt) 


           endlocal 


           :echo 


           setlocal ENABLEDELAYEDEXPANSION 


           for /f %%i in (tmp1.txt) do ( 


           set n=%%i 


           set m=!m! !n! 


           ) 


           del tmp*.txt 


           cls 


           echo. 


           echo.¥1000000000000000000000000000000000000000000.00 


           echo. 


           echo. Hitme,雙色球必中,號(hào)碼是 !m! 


           echo. 


           echo.¥1000000000000000000000000000000000000000000.00 


           echo. 


           :save 


           set /p x=保留號(hào)碼至num.txt[y/n] 


           if /i [%x%]  [y] (echo !m!>>num.txt && endlocal && goto :start) else 


            (endlocal && goto :start) 


           ab.rar 


25.  &  


           for windows2000+ 


           @echo off 


           :run 


           for /F "tokens=2" %%i in ('netstat -e ^| find "Bytes"') do set 


           down1=%%i 


           for /F "tokens=3" %%i in ('netstat -e ^| find "Bytes"') do set 


           up1=%%i 


           ping -w 850 -n 1 1.1.1.1 2>nul >nul 


           for /F "tokens=2" %%i in ('netstat -e ^| find "Bytes"') do set /a 


           down=(%%i-%down1%)/1024 


           for /F "tokens=3" %%i in ('netstat -e ^| find "Bytes"') do set /a 


           up=(%%i-%up1%)/1024 


           cls 


           echo Down %down% KB 


           echo Up   %up% KB 


           title %down% KB Down %up% KB Up 


           goto:run 


           -------------------------------------- 


           @echo off 


           start /wait regedit /e tmp1.txt 


           "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices\" 


           for /f "tokens=3 delims=\:" %%i in ('find "\\DosDevices\\" 


           tmp1.txt') do echo %%i >>tmp2.txt 


           setlocal ENABLEDELAYEDEXPANSION 


           for %%i in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do find 


           "%%i" tmp2.txt 2>nul >nul|| set n=!n!:,%%i 


           echo freedrv=!n:~2! 


           endlocal 


           pause 


           att-1.rar 


26. TOP10 


          功能:列出特定目錄下最新目錄名TOP10 


          可以利用ftp登錄顯示最近更新的東西,方便抓取特定目錄到最近更新的目錄 


          測試 


          用法,cmd下 


          t_ls /top數(shù)量 目錄名 


          1,以為if不能else,原來else (要帶個(gè)空 


          2,%var:~n,m% 


          3,more +n| 去掉前幾行,嘿,在管道里沒有more作用 


          4,setlocal ENABLEDELAYEDEXPANSION ,在for里可以用累“加”了。 


          5,%var:string1=string2% 替換 


          6,!var! 用在delayedexpansion 


          @echo off 


          cls 


          echo. 


          echo.....列表中....請(qǐng)少等 


          echo. 


          if "%1"  "" goto :syntax 


          if "%1"  "/?" goto :syntax 


          if "%1"  "/" goto :syntax 


          if "%1"  "?" goto :syntax 


          if "%1"  "/help" goto :syntax 


          setlocal  ENABLEDELAYEDEXPANSION 


           :input 


          set n=%1 


          if "%n:~0,1%"  "/" ( 


              for /l %%i in (0,1,%n:~1%) do set var=!var! %%i:. 


              set m=%* 


               set m=!m:%n% =!) else ( 


                           for /l %%i in (0,1,10) do set var=!var! %%i:. 


                           set m=%* 


           ) 


           :head 


           (echo.^<head^> 


           echo.^<title^>列表目錄下最新目錄名TOP10^</title^> 


           echo.^<meta http-equiv="Content-Type" content="text/html^; 


           charset=gb2312" ^/^> 


           echo.^<style type="text/css"^> 


           echo.^<!-- 


           echo.a:active { text-decoration: none ; color: red ; font-size: 12pt 


           } 


           echo.a:visited { text-decoration: none ; color: green ; font-size: 


           12pt } 


           echo.a:link { text-decoration: none ; font-size: 12pt } 


           echo.--^> 


           echo.^</style^> 


           echo.^</head^> 


           echo.^<h1^>        列表目錄下最新目錄名TOP10                     ^</h1^>    


           echo.  written by hitme 2005.9.3 


           echo.^</br^>)>list.htm 


           :list 


           for /f "delims=" %%i in ('dir "!m!\" /ad/b/tc/o-d^|more +0 


                                              ') do ( 


                       (echo.----------------------------------- 


                        echo.^</br^> 


                        echo.^<a href="!m!\%%i"^>"!m!\%%i"^</a^> 


                        echo.^</br^> 


                        echo.^</br^>)>>list.htm 


                       for /f "tokens=1-5* delims=: " %%a in ('dir "!m!\%%i" 


           /ad/tc/o-d^|more +5^|findstr /v /c:"<DIR>          ."^|findstr /n 


           "."^|findstr /r /b "!var!" 


                                     ') do ( 


                               if "%%f" neq ""    ( 


                               >>list.htm echo.^<a href="!m!\%%i\%%f"^>%%a: 


          %%b %%c:%%d    %%f^</a^> 


                              >>list.htm echo.^</br^>) 


                      ) 


           ) 


           start list.htm 


           endlocal 


           goto:eof 


           :syntax 


           cls 


           echo. 


           echo.T_ls.cmd 


           echo. 


           echo.written by hitme    2005.9.3 


           echo. 


           echo.用法: 


           echo.    t_ls /top數(shù)量 目錄名 


           echo. 


           echo.例如: 


           echo.    t_ls c:windows 


           echo.    t_ls /20 c: 


           echo. 


           T_ls-1.rar 


27.  


           renx.rar 


28.  


           今天格了盤,忘了備綠色/準(zhǔn)綠色程序的快截方式,目錄進(jìn)進(jìn)出出實(shí)在煩 


           explorer搜索*.exe,右鍵拖出快捷方式,受到非入口exe的干擾,迷眼睛啊 


           想辦法呀,想辦法呀,cmd濾一下 


           兩個(gè)策略: 


          1,枚舉路徑,如本層路徑下存在有exe文件,則不深入到下一層 


          2,濾出上次訪問時(shí)間最新的exe文件,就當(dāng)它是入口吧,眼睛是我們寶貴的辯識(shí) 


          力量 


          偶然發(fā)現(xiàn)的好處: 


          1.發(fā)掘出了幾個(gè)壓箱底的東東 


          2.如本身有較好的分類,稍改下cmd,也能實(shí)現(xiàn)lnk的自動(dòng)分類 


          @echo off 


          echo. 


          echo. 


          echo.批量跑出程序的快捷方式.cmd by hitme 2005.5.11 


          echo. 


          echo.稍等... 


          :P1 


          ::*********************************************************** 


          ::#列表路徑 


          ::#濾鏡1:路徑下存在有exe文件 


          ::#濾鏡1:枚舉路徑,如本層路徑下存在有exe文件,則不深入到下一層 


          ::*********************************************************** 


          setlocal ENABLEDELAYEDEXPANSION 


          for /f "delims=" %%i in ('dir /s/b *.exe ^| findstr /v /i 


          "shortcut\.exe$"') do ( 


          find "%%~dpi" tmp.txt>nul || ( 


                echo %%~dpi | find "!n!">nul || ( 


                         echo %%~dpi>>tmp.txt 


                         set n=%%~dpi 


                         ) 


                   ) 


          ) 


          endlocal 


          :P2 


          ::*********************************************************** 


          ::#以P1路徑列表為原料,繼續(xù)加工 


          ::#過濾上次訪問時(shí)間最新的exe文件 


          ::*********************************************************** 


          for /f "delims=" %%i in (tmp.txt) do ( 


                           dir /ta "%%i*.exe" | sort /r | findstr /n "." | 


           findstr /r "^1:">>tmp1.txt 


           ) 


           :P3 


           ::*********************************************************** 


           ::#同行合并P1,P2=>list.txt 


           ::*********************************************************** 


           set /a N1=0 


           for /f %%i in (tmp.txt) do set /a N1+=1 


           for /l %%a in (1,1,%N1%) do ( 


           for /f "tokens=1* delims=:" %%i in ('findstr /n "." tmp.txt 


           ^|findstr /r "^%%a:"') do set dir=%%j 


           for /f "tokens=3*" %%i in ('findstr /n "." tmp1.txt ^|findstr /r 


           "^%%a:"') do set filename=%%j 


           setlocal ENABLEDELAYEDEXPANSION 


           echo !dir!!filename! 


           echo !dir!!filename!>>list.txt 


           endlocal 


           ) 


           :shortcut 


           ::*********************************************************** 


           ::#依據(jù)list.txt路徑列表,創(chuàng)建link 


           ::*********************************************************** 


           pause 


           for /f "delims=" %%i in (list.txt) do ( 


           shortcut -d %%~dpi "%%i" 


           ) 


           :clean 


           ::*********************************************************** 


           ::#打掃衛(wèi)生 


           ::*********************************************************** 


           del tmp*.txt list.txt 2>nul 


           creat_shortcut.rar 


29. n 


           copy自yesterday.vbs 


           搞不明白如何將vbs變量傳遞給cmd變量,算了,用 


           for...('cscript.exe..)..來取了 


           用法:cmd下 


           del_day 5 


           刪除文件修改時(shí)間為5天前的文件,測試,刪除操作務(wù)必謹(jǐn)慎 


           @echo off 


           >t_day.vbs  echo ' Yesterday.vbs,  Version 1.01 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Written by Rob van der Woude 


           >>t_day.vbs echo ' http://www.robvanderwoude.com 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Calculate yesterday's date 


           >>t_day.vbs echo    dtmYesterday = DateAdd("d",-%1,Date) 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Get yesterday's year 


           >>t_day.vbs echo    strYear      = DatePart("yyyy",dtmYesterday) 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Get yesterday's month, add leading zero if 


           necessary 


           >>t_day.vbs echo    If DatePart("m",dtmYesterday) ^< 10 Then 


           >>t_day.vbs echo    strMonth = 0 ^& DatePart("m",dtmYesterday) 


           >>t_day.vbs echo    Else 


           >>t_day.vbs echo    strMonth = DatePart("m",dtmYesterday)           


           >>t_day.vbs echo    End If 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Get yesterday's day, add leading zero if 


           necessary  


           >>t_day.vbs echo    If DatePart("d",dtmYesterday) ^< 10 Then 


           >>t_day.vbs echo   strDay = 0 ^& DatePart("d",dtmYesterday)        


           >>t_day.vbs echo    Else 


           >>t_day.vbs echo   strDay = DatePart("d",dtmYesterday)            


           >>t_day.vbs echo    End If 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Format output for yesterday 


           >>t_day.vbs echo   strYest = strYear ^& strMonth ^& strDay 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' echo 


           >>t_day.vbs echo Wscript.echo( strYest ) 


           @echo on 


           for /f "delims=" %%i in ('cscript.exe //nologo t_day.vbs') do set 


           t_day=%%i 


           setlocal ENABLEDELAYEDEXPANSION 


           for /r %%i in (*.*) do set c_day=%%~ti && if 


           "!c_day:~0,2!!c_day:~3,2!!c_day:~6,2!" lss "%t_day:~2,6%" del /q 


           "%%i" 


           endlocal 


           cls 


           @echo  


           @echo 刪除完畢. 


           @echo  


30. “” 


           以明星寫真為例;http://www.imagegarden.net/material/index.php?s 


           保存為.cmd運(yùn)行,albumid從595到2210 


           @echo off 


           set /a _n_=595 


           :loop 


           curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -o 


           tmp.txt 


           http://www.imagegarden.net/viewimage.php?s=^&cataid=4^&albumid=2202^ 


           &imageid=8^&type=jpeg 


           for /f "tokens=4 delims  &" %%i in ('findstr 


           "cataid=4&albumid=2202&imageid=8&type=jpeg" tmp.txt') do ( 


           set _session_=%%i 


           ) 


           set /a _n_=%_n_%+1 


           if %_n_%  2210 goto :clean 


           md %_n_% 


           del /q *.jpg 2>nul 


           :dl 


           for /l %%a in (1,1,9) do ( 


           curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -o 


           %_n_%_00%%a.jpg 


           http://www.imagegarden.net/image_a.php?imagesession=%_session_%^&cat 


           aid=4^&albumid=%_n_%^&imageid=%%a^&type=jpeg 


           for %%i in (%_n_%_*.jpg) do ( 


           if %%~zi  11527 (goto :loop) else move *.jpg %_n_% 


           ) 


           ) 


           for /l %%a in (10,1,99) do ( 


           curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -o 


           %_n_%_0%%a.jpg 


           http://www.imagegarden.net/image_a.php?imagesession=%_session_%^&cat 


           aid=4^&albumid=%_n_%^&imageid=%%a^&type=jpeg 


           for %%i in (%_n_%_*.jpg) do ( 


           if %%~zi  11527 (goto :loop) else move *.jpg %_n_% 


           ) 


           ) 


           for /l %%a in (100,1,999) do ( 


           curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -o 


           %_n_%_%%a.jpg 


           http://www.imagegarden.net/image_a.php?imagesession=%_session_%^&cat 


           aid=4^&albumid=%_n_%^&imageid=%%a^&type=jpeg 


           for %%i in (%_n_%_*.jpg) do ( 


           if %%~zi  11527 (goto :loop) else move *.jpg %_n_% 


           ) 


           ) 


           :clean 


           for /r %%i in (.) do rd /q "%%i" 


           del /q *.jpg 


           del /q tmp.txt 


           dl-1.rar 


31.  


           對(duì)象: 


           http://www.sophoto.cn/photopost/showgallery.php?si=&perpage=24&sort 


           1&cat=501&ppuser 


           目標(biāo):得到圖片url,方便flashget批量下載 


          簡單看下頁面:連接有分大中小圖,規(guī)模為12*41張左右 


          思路: 


          curl抓取41個(gè)縮略頁面,分析出縮略圖url 


           由于圖片命名具有規(guī)律,縮掠與大圖的區(qū)別在于結(jié)尾 


          thumb.gif -thumb.jpg =縮略圖 


          .gif .jpg =大圖 


          med.jpg =中圖 


          這下更簡單了,抓取時(shí),替換部分url內(nèi)容即可 


          保存為.cmd運(yùn)行 


          需要curl 


          @echo off 


          curl -o #1.htm 


          http://www.sophoto.cn/photopost/showgallery.php?cat=501^&si=^&page=[ 


          1-41]^&sort=1^&perpage=12^&password=0^&ppuser=^&what=^&name=^& 


          setlocal  ENABLEDELAYEDEXPANSION 


          for /f "tokens=9 delims  " %%i in ('findstr /r 


          "http://www\.sophoto\.cn/photopost/data/" *.htm') do ( 


          set n=%%i 


          set n=!n:-thumb.gif" alt=.gif! 


          set n=!n:-thumb.jpg" alt=.jpg! 


          set n=!n:-thumb.jpeg" alt=.jpeg! 


          set n=!n:"=! 


          echo !n! >>list.txt 


          ) 


          endlocal 


          del *.htm 


          start list.txt 


          list.txt 


32.  


          下載www.sky-fire.com的100多部漫畫 


          毛估有幾十萬張的漫畫圖片 


          需要curl 


33.  


          述求:批量下載http://www.wulffmorgenthaler.com/中的每日?qǐng)D片 


          圖片都是這個(gè)格式 


          http://www.wulffmorgenthaler.com/log/xxxxxxxxx.gif 


          開工: 


          1.找文件名規(guī)律,gif文件名有兩位隨機(jī)位,碰壁 


          2.查看htm文件 


          ,http://www.wulffmorgenthaler.com/thestrip.asp?cDay=09&cMonth=05&cY 


          ear=2005,帶年月日,有規(guī)律真好 


          3.列表年月日,備用 


          4.出動(dòng)curl,下載htm,分析htm,下載gif 


          5.收工 


          保存為get_gif.cmd運(yùn)行,自行修改紅色部分,現(xiàn)表示下載前10天的gif文件 


          需要curl 


          @echo off 


          ::/ * list date */ 


           set /a n=0 


           :loop 


           set /a n+=1 


           >t_day.vbs  echo ' Yesterday.vbs,  Version 1.01 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Written by Rob van der Woude 


           >>t_day.vbs echo ' http://www.robvanderwoude.com 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Calculate yesterday's date 


           >>t_day.vbs echo    dtmYesterday = DateAdd("d",-%n%,Date)       


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Get yesterday's year 


           >>t_day.vbs echo    strYear      = DatePart("yyyy",dtmYesterday) 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Get yesterday's month, add leading zero if 


           necessary 


           >>t_day.vbs echo    If DatePart("m",dtmYesterday) ^< 10 Then 


           >>t_day.vbs echo    strMonth = 0 ^& DatePart("m",dtmYesterday) 


           >>t_day.vbs echo    Else 


           >>t_day.vbs echo    strMonth = DatePart("m",dtmYesterday)           


           >>t_day.vbs echo    End If 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Get yesterday's day, add leading zero if 


           necessary  


           >>t_day.vbs echo    If DatePart("d",dtmYesterday) ^< 10 Then 


           >>t_day.vbs echo   strDay = 0 ^& DatePart("d",dtmYesterday)        


           >>t_day.vbs echo    Else 


           >>t_day.vbs echo   strDay = DatePart("d",dtmYesterday)            


           >>t_day.vbs echo    End If 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' Format output for yesterday 


           >>t_day.vbs echo   strYest = strYear ^& strMonth ^& strDay 


           >>t_day.vbs echo ' 


           >>t_day.vbs echo ' echo 


           >>t_day.vbs echo Wscript.echo( strYest )   


           for /f "delims=" %%i in ('cscript.exe //nologo t_day.vbs') do echo 


           %%i>>tmp.txt 


           if %n% neq 10 goto :loop 


            ::/ * get htm&gif * / 


           for /f "delims=" %%i in (tmp.txt) do ( 


           setlocal ENABLEDELAYEDEXPANSION 


           set n=%%i 


           curl -o !n!.htm 


           http://www.wulffmorgenthaler.com/thestrip.asp?cDay=!n:~- 


           2!^&cMonth=!n:~4,2!^&cYear=!n:~0,4! 


           for /f "tokens=4 delims  " %%j in ('findstr "log" *.htm') do ( 


           set m=%%j 


           curl -o !m:~5,-5! http://www.wulffmorgenthaler.com/!m:~1,-5! 


           ) 


           del *.htm 


           endlocal 


           ) 


           ::/ * clean * / 


           del tmp.txt 


           get_gif.rar 


34.  


           7.9更新,支持分次下載 


           http://automobile.2405.com/ 


           這里面的汽車圖片不錯(cuò).想辦法把它全部下載下來 


           測試下,保存為dl.cmd運(yùn)行 


           需要curl 


           @echo off 


           setlocal  ENABLEDELAYEDEXPANSION 


           for /f "tokens=2 delims  " %%i in ('curl 


           http://automobile.2405.com/index.html ^|findstr 


           "automotive_catalog"') do ( 


           set n=%%i 


           curl http://automobile.2405.com/!n:~1,-7! |findstr 


           "automobile_gallery" >tmp.txt 


           for /f "tokens=2 delims  " %%a in (tmp.txt) do ( 


           set m=%%a 


           curl http://automobile.2405.com/!m:~4,-7!/index.html |findstr "jpg" 


           >tmp1.txt 


          set x=!n:~1,-7!!m:~4,-7! 


          set x=!x:/=\! 


          md !x! 2>nul 


          for /f "tokens=2 delims  " %%b in (tmp1.txt) do ( 


               set l=%%b 


           if not exist "!x!\!l:~1,-10!" curl -o "!x!\!l:~1,-10!" 


          http://automobile.2405.com/!m:~4,-7!!l:~1,-10! 


          ) 


          ) 


          ) 


          endlocal 


          del tmp*.txt 


          dl.rar 


35. txt 


          有時(shí)候不太方便先cut&copy去別處,再del,又想要一點(diǎn)點(diǎn)自動(dòng)化感覺的 


          cmd下 


          for /f "delims=/" %i in ('dir /b/s *.*') do dir /b/s *.txt | find 


          "%i" || del "%i" 


          需保留下數(shù)種類型? 


          例:保留txt rar 


          for /f "delims=/" %i in ('dir /b/s *.*') do dir /b/s *.txt *.rar| 


          find "%i" || del "%i" 


36.  


          功能:掛接網(wǎng)絡(luò)中某主機(jī)(例如:192.168.1.99)的全部共享為網(wǎng)絡(luò)驅(qū)動(dòng)器 


          用法:cmd下運(yùn)行mntshare /? 


          net view \\ip的輸出太過bt 


          共享名過長時(shí)列表錯(cuò)行,共享名含空格又造成for抓取困難(字段間隔非跳格鍵 


          ,而是空格) 


          就是要搞翻它。。。 


          出個(gè)嗖招:利用了類型Disk字段定位,把文本行翻過來,替換,倒回去。。 


          呵呵,堅(jiān)持,堅(jiān)持就是勝利,測試下 


          順便感慨下。。。裸奔cmd的文本替換能力太肉了.. 


          想想還是吃飽了撐的, xp以后的系統(tǒng)都帶自動(dòng)掃描了,給2000頂一頂好了 


          @echo off 


          echo.主機(jī)%1共享掛接中......... 


          del tmp.txt 2>nul 


          if "%1"  "" goto :syntax 


          if "%1"  "/?" goto :syntax 


          if "%1"  "/" goto :syntax 


          if "%1"  "?" goto :syntax 


          if "%1"  "/help" goto :syntax 


          setlocal ENABLEDELAYEDEXPANSION 


          for /f "delims=" %%i in ('net view \\%1 ^|more +7') do ( 


          set n=%%i 


          set r_n 


          for /l %%a in (1,1,40) do ( 


          if "!n!"  "" set n 


          set n1=!n:~0,1! 


          set n=!n:~1! 


          set r_n=!n1!!r_n! 


          ) 


          set r_n=!r_n:*ksiD=! 


          echo !r_n!>>tmp.txt 


          ) 


          for /f "tokens=*" %%j in (tmp.txt) do ( 


          set m=%%j 


          set r_m 


          for /l %%b in (1,1,40) do ( 


           if "!m!"  "" net use * "\\%1\!r_m!" /persistent:yes 2>nul >nul 


           set m1=!m:~0,1! 


           set m=!m:~1! 


           set r_m=!m1!!r_m! 


           ) 


           ) 


           endlocal 


           cls 


           echo. 


           echo.掛接主機(jī)%1共享完成。 


           echo. 


           net use |more +5 


           pause 


           del tmp.txt 2>nul 


           explorer /e 


           :syntax 


           cls 


           echo. 


           echo.mntshare.cmd  掛接網(wǎng)絡(luò)共享cmd腳本 


           echo. 


           echo.written by hitme    2005.8.16 


           echo. 


           echo.用法: 


           echo.mntshare ip或者主機(jī)名 


           echo. 


           echo.例如: 


           echo.mntshare 192.168.1.99 


           echo.mntshare mycomputer 


           echo. 


           echo.刪除掛接請(qǐng)使用 net use * /delete 


           echo. 


           pause 


           mntshare.rar 


37. () 


          閑來無聊,瞎搞個(gè)簡易網(wǎng)絡(luò)信息搜集 


          現(xiàn)包括 


          1.IP與Mac Address對(duì)應(yīng)表 


          2.IP與Hostname對(duì)應(yīng)表 


          3.IP與Workgroup對(duì)應(yīng)表 


          4.查詢WHO是主控域?yàn)g覽器? 


          全部基于nbtstat命令,鬧著玩 


          @echo off 


          setlocal 


          :menu 


          cls 


          mode con:cols=80 lines=25 


          title  網(wǎng)絡(luò)信息搜集(簡易) 


          color f2 


          echo. 


          echo.*********************** 


          echo.       網(wǎng)絡(luò)信息搜集(簡易) 


          echo.*********************** 


          echo.1.IP與Mac Address對(duì)應(yīng)表 


          echo. 


          echo.2.IP與Hostname對(duì)應(yīng)表 


          echo. 


          echo.3.IP與Workgroup對(duì)應(yīng)表 


          echo. 


          echo. 


          echo.4.查詢WHO是主控域?yàn)g覽器? 


          echo. 


          echo. 


          echo.x.退出 


          echo.--------------------------------------------------------------- 


          --- 


          :input 


          set /p x=請(qǐng)選擇項(xiàng)目號(hào): 


           if /i "%x%"  "x" goto :end 


           echo. 


           set /p y=請(qǐng)輸入IP范圍(例如:192.168.1.1-254): 


           for /f "tokens=1-5 delims=.-" %%a in ("%y%") do ( 


           set ip=%%a.%%b.%%c 


           set n1=%%d 


           set n2=%%e 


           ) 


           if "%x%"  "1" goto :mac 


           if "%x%"  "2" goto :hostname 


           if "%x%"  "3" goto :group 


           if "%x%"  "4" goto :msbrowse 


           endlocal 


           ::------------------------------------------------------------------ 


           ----------- 


           :mac 


           setlocal 


           cls 


           mode con:cols=40 lines=40 


           color f4 


           title IP與Mac Address對(duì)應(yīng)表 


           echo.IP ^<=^> MAC Address's Table 


           echo. 


           ( 


           echo.IP ^<=^> MAC Address's Table 


           echo. 


           ) >mac.txt 


           for /l %%i in (%n1%,1,%n2%) do ( 


           ping -n 1 -w 1 %ip%.%%i |find "Reply" >nul 2>nul && ( 


           for /f "tokens=2 delims  " %%a in ('nbtstat -a "%ip%"."%%i"^|findstr 


           /c:"MAC Address"') do ( 


           echo.%ip%.%%i%%a 


           echo.%ip%.%%i%%a>>mac.txt 


           ) 


           ) 


           ) 


           findstr /n "." mac.txt |findstr /r "^3:" && start mac.txt 


           endlocal 


           goto :menu 


           ::------------------------------------------------------------------ 


           ---------- 


           :hostname 


           setlocal 


           cls 


           mode con:cols=40 lines=40 


           color f5 


           title Ip與Hostname對(duì)應(yīng)表 


           echo.IP ^<=^> Host_name's Table 


           echo. 


           ( 


           echo.IP ^<=^> Host_name's Table 


           echo. 


           ) >hostname.txt 


           for /l %%i in (%n1%,1,%n2%) do ( 


           ping -n 1 -w 1 %ip%.%%i |find "Reply" >nul 2>nul && ( 


           for /f  %%b in ('nbtstat -a "%ip%"."%%i"^|findstr /r /c:"\<20\> 


           UNIQUE"') do ( 


           echo.%ip%.%%i%%b 


           echo.%ip%.%%i%%b>>hostname.txt 


           ) 


           ) 


           ) 


           findstr /n "." hostname.txt |findstr /r "^3:" && start hostname.txt 


           endlocal 


           goto :menu 


           ::------------------------------------------------------------------ 


           ------------ 


           :group 


           setlocal 


           cls 


           mode con:cols=40 lines=40 


           color f1 


           title IP與Workgroup對(duì)應(yīng)表 


           echo.IP ^<=^>Group Name's Table 


           echo. 


           ( 


           echo.IP ^<=^>Group Name's Table 


           echo. 


           ) >group.txt 


           for /l %%i in (%n1%,1,%n2%) do ( 


           ping -n 1 -w 1 %ip%.%%i |find "Reply" >nul 2>nul && ( 


           for /f  %%c in ('nbtstat -a "%ip%"."%%i"^|findstr /r /c:"\<00\> 


           GROUP"') do ( 


           echo.%ip%.%%i%%c 


           echo.%ip%.%%i%%c>>group.txt 


           ) 


           ) 


           ) 


           findstr /n "." group.txt |findstr /r "^3:" && start group.txt 


           endlocal 


           goto :menu 


           :msbrowse 


           cls 


           title 查詢WHO是主控域?yàn)g覽器? 


           echo.查詢中......... 


           for /l %%i in (%n1%,1,%n2%) do ( 


           ping -n 1 -w 1 %ip%.%%i |find "Reply" >nul 2>nul && ( 


           nbtstat -a %ip%.%%i|findstr "__MSBROWSE__" 2>nul >nul && ( 


           echo.主控域?yàn)g覽器是:%ip%.%%i 


           pause 


           goto :menu 


           ) 


           ) 


           ) 


           cls 


           echo.未找到......汗 & pause & goto:menu 


           :end 


                cls 


                echo. 


                echo.written by hitme 2005.08.18 


                pause 


                goto :eof 


                net_Tab.rar 


38. cmd 


39.  


                閑來無聊,瞎搞一個(gè),測試 


                功能:統(tǒng)計(jì)每個(gè)單詞在文本中出現(xiàn)的次數(shù) 


                用法: 


                cmd下 


                word_num 文件名 


                統(tǒng)計(jì)結(jié)果樣式: 


                0152 fixed 


                0108 added 


                0094 in 


                0091 to 


                0070 will 


                0069 not 


                0062 problem 


                0059 the 


                0056 bar 


                0054 support 


                0054 at 


                0053 and 


                0050 for 


                0047 menu 


           0046 tab 


           0042 when 


           0041 new 


           0040 option 


           0040 changed 


           0038 myie2 


           0037 plugin 


           0036 favorite 


           0035 toolbar 


           0035 on 


           代碼 


           @echo off 


           cls 


           echo. 


           echo.----------------------------- 


           echo....統(tǒng)計(jì)中.....請(qǐng)少等... 


           echo.----------------------------- 


           echo. 


           if "%*"  "" goto :syntax 


           if "%*"  "/?" goto :syntax 


           if "%*"  "/" goto :syntax 


           if "%*"  "?" goto :syntax 


           if /i "%*"  "/help" goto :syntax 


           :: /* 拆解文本為每行一單詞 */ 


           setlocal ENABLEDELAYEDEXPANSION 


           del end.txt tmp*.txt 2>nul 


           set /a m=0 


           :loop 


           set /a m+=1 


           for /f "tokens=%m% delims=.,:;/[]()!'@=\<> " %%i in (%*) do ( 


           set n=%%i 


           set n=!n:"=! 


           echo.1 !n!>>tmp.txt 


           ) 


           if "%m%"  "200" goto:add 


           goto:loop 


           endlocal 


           :add 


           :: /* 分類匯總 */ 


           setlocal ENABLEDELAYEDEXPANSION 


           for /f "tokens=1,2" %%i in ('sort tmp.txt^|findstr /r "^1\ [a-z][A- 


           Z]"') do ( 


           if /i "!y!"  "%%j" ( 


           set /a x+=1) else (if "!x!" neq "" ( 


           if !x! lss 10 (echo.000!x! !y!>>tmp1.txt) else ( 


           if !x! lss 100 (echo.00!x! !y!>>tmp1.txt) else ( 


           if !x! lss 1000 (echo.0!x! !y!>>tmp1.txt)))) 


           set y=%%j 


           set x=%%i) 


           ) 


           if !x! lss 10 (echo.000!x! !y!>>tmp1.txt) else ( 


           if !x! lss 100 (echo.00!x! !y!>>tmp1.txt) else ( 


           if !x! lss 1000 (echo.0!x! !y!>>tmp1.txt))) 


           endlocal 


           sort /r tmp1.txt>tmp2.txt 


           :ex 


           :: /* 大寫轉(zhuǎn)小寫 */ 


           setlocal ENABLEDELAYEDEXPANSION 


           for /f "delims=" %%i in (tmp2.txt) do ( 


           set ex=%%i 


           set ex=!ex:A=a! 


           set ex=!ex:B=b! 


           set ex=!ex:C=c! 


           set ex=!ex:D=d! 


           set ex=!ex:E=e! 


           set ex=!ex:F=f! 


           set ex=!ex:G=g! 


           set ex=!ex:H=h! 


           set ex=!ex:I=i! 


           set ex=!ex:J=j! 


           set ex=!ex:K=k! 


           set ex=!ex:L=l! 


           set ex=!ex:M=m! 


           set ex=!ex:N=n! 


           set ex=!ex:O=o! 


           set ex=!ex:P=p! 


           set ex=!ex:Q=q! 


           set ex=!ex:R=r! 


           set ex=!ex:S=s! 


           set ex=!ex:T=t! 


           set ex=!ex:U=u! 


           set ex=!ex:V=v! 


           set ex=!ex:W=w! 


           set ex=!ex:X=x! 


           set ex=!ex:Y=y! 


           set ex=!ex:Z=z! 


           echo.!ex!>>end.txt 


           ) 


           del tmp*.txt 


           start end.txt 


           :syntax 


           cls 


           echo. 


           echo.word_num.cmd 


           echo. 


           echo.written by hitme 2005.9.2 


           echo.用法: 


           echo.word_num 文件名 


           echo. 


           echo.例如: 


           echo.word_num License.txt 


           echo. 


                                                   統(tǒng)計(jì)中文字的,用法同頂樓,想 


           辦法搞成豎排一列,試試 


           代碼: 


           @echo off 


           setlocal ENABLEDELAYEDEXPANSION 


           for /f "delims=" %%i in (%1) do ( 


                       set n=%%i    


                       echo.!n!>tmp.txt 


                       echo.x>>tmp.txt 


                       for /f "tokens=1 delims=:" %%a in ('findstr /o "x" 


           tmp.txt') do set lenth=%%a 


                       for /l %%a in (0,1,!lenth!) do ( 


                               set m=!n:~%%a,1! 


                               if "!m!" neq "" echo.1 !m!>>tmp1.txt 


                       ) 


           ) 


            :add 


           for /f "tokens=1,2" %%i in ('sort tmp1.txt') do ( 


                       if "!y!"  "%%j" ( 


                               set /a x+=1) else (    if "!x!" neq "" ( 


                                           if !x! lss 10 (echo.000!x! 


            !y!>>tmp2.txt) else ( 


                                           if !x! lss 100 (echo.00!x! 


            !y!>>tmp2.txt) else ( 


                                           if !x! lss 1000 (echo.0!x! 


            !y!>>tmp2.txt)))) 


                                           set y=%%j 


                                           set x=%%i) 


           ) 


           if !x! lss 10 (echo.000!x! !y!>>tmp2.txt) else ( 


           if !x! lss 100 (echo.00!x! !y!>>tmp2.txt) else ( 


           if !x! lss 1000 (echo.0!x! !y!>>tmp2.txt))) 


           endlocal 


           sort /r tmp2.txt>end.txt 


           del tmp*.txt 


           start end.txt 


          word_num.rar 


40. sample 


          設(shè)源文件為text.txt 


          欲替換problem為hitme,最簡單的替換 


          代碼: 


           setlocal  ENABLEDELAYEDEXPANSION 


          for /f "delims=" %%i in (text.txt) do set n=%%i && set 


          m=!n:problem=hitme! && echo !m! >>replace.txt 


           endlocal 


           start replace.txt 


          att-2.rar 


41. usb& 


          請(qǐng)謹(jǐn)慎使用 


          devcon挺好使的,就為推薦它 


          @echo off 


          for /f %%i in ('devcon findall ^=usb ^| find ":"') do devcon remove 


           "@%%i" 


          for /f %%i in ('devcon findall usb* ^| find ":"') do devcon remove 


           "@%%i" 


          devcon rescan 


          renew_usb.rar 


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)