---------- 把同一文件拷貝到所有子目錄中.BAT
@echo off
for /r . %%a in (.) do copy 文件名 %%a
---------- 遍歷可用ip地址,小心被網(wǎng)管k死.BAT
@set YAHOO=66.218.71.90
@set IP=200
@set TIMEOUT=500
:Loop
@netsh interface ip set address name="本地連接" source=static addr=192.168.0.%ip% mask=255.255.255.0 192.168.0.1 1
@echo.
@echo Checking 192.168.0.%IP%
@ping -n 1 -w %TIMEOUT% %YAHOO% | find "Reply"
@set /a ip=%ip%+1
@if %ip% EQU 255 goto :End
@goto :Loop
:End
---------- WINRAR嵌套解壓縮.BAT
@echo off
for /l %i in (1,1,3) do rar x -r -o- .
---------- WINXP怎樣通過腳本實(shí)現(xiàn)從文本中截取字符串再作為命令的參數(shù)運(yùn)行.TXT
route print 163.200.0.0 >1.txt
for /f "skip=8 tokens=3" %i in (1.txt) do route add 162.200.0.0 mask 255.255.0.0 %i && exit
WinXP的機(jī)器。
我希望從命令如"route print 163.200.0.0"的輸出結(jié)果中截取出網(wǎng)關(guān)IP地址,再將另一網(wǎng)段的路由指向該網(wǎng)關(guān),如“route add 162.200.0.0 <網(wǎng)關(guān)IP>”,在UNIX下可以作到,不知能否通過Win的批處理命令或其它腳本實(shí)現(xiàn)?
我對(duì)Win下的腳本無(wú)任何使用經(jīng)驗(yàn),請(qǐng)幫忙!謝謝!
訂正:
for /f "skip=8 tokens=3" %i in ('route print 163.200.0.0') do route add 162.200.0.0 mask 255.255.0.0 %i && exit
---------- 遍歷盤取文件路徑.BAT
@echo off
for /r %%I in (*.*) do echo %%~fnI >> c:\列表.txt
---------- 遍歷盤取文件路徑1.BAT
@echo off
dir /a:d /s /a /b >c:\list.txt
---------- 檢看局域網(wǎng)內(nèi)網(wǎng)卡的MAC.BAT
@echo off
for /l %%a in (1,1,254) do ping -n 1 -w 10 192.168.0.%%a
arp -a
---------- 建立當(dāng)前日期目錄.BAT
set today=%date:~4,10%
md "today"
---------- 將某個(gè)盤里的所有EXE覆蓋到另一個(gè)盤的相應(yīng)目錄.BAT
xcopy *.exe 目標(biāo)路徑\. /s/e/y
---------- 復(fù)制目錄結(jié)構(gòu),而不復(fù)制目錄下的文件.BAT
xcopy /t/e
---------- 每個(gè)文件生成一個(gè)同名文件夾,然后把各個(gè)文件拷貝到同名文件夾中.BAT
@echo off
for %%a in (*.*) do mkdir "%%~na"
for %%a in (*.*) do copy %%a "%%~na"
---------- 掃描一個(gè)網(wǎng)段.用FOR和PING.然后得到存活主機(jī)把結(jié)果存為IP和IP之間用,隔開.BAT
for /l %%i in (1,1,254) do ping -n 1 192.168.0.%%i | find "Reply" >>1.txt
for /f "tokens=3" %%i in (1.txt) do echo %%i >>2.txt
for /f "tokens=1 delims=:" %%i in (2.txt) do echo %%i, >>3.txt
del 1.txt 2.txt && cls && type 3.txt && pause
訂正:
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)
---------- 刪除指定大小文件,拷貝,移動(dòng),改名.BAT
@echo off
for /r %%a in (*.jpg,*.jpeg,*.png) do if %%~za lss 50000 del /q "%%a"
---------- 刪除指定擴(kuò)展類型文件,拷貝,移動(dòng),改名.BAT
@echo off
for /r %%a in (*.htm,*.html,*.gif,*.js,*.bmp) do del /q "%%a"
---------- 刪除指定擴(kuò)展類型文件.BAT
del /s/f/q *.exe
---------- 生成001.TXT 002.TXT 999.TXT 文本內(nèi)容分別是TEXT001 TEXT002.BAT
@echo off
for /l %%a in (1,1,9) do @echo text00%%a >00%%a.txt
for /l %%a in (10,1,99) do @echo text0%%a >0%%a.txt
for /l %%a in (100,1,999) do @echo text%%a >%%a.txt
---------- 刷新網(wǎng)卡.BAT
@echo off
nbtstat -RR
ipconfig /flushdns
ipconfig /renew
ipconfig /release
---------- 死循環(huán).BAT
@echo off
for /l %%a in (1,0,2) do dir %%a
---------- 向目錄里的每個(gè)文件夾里面都COPY一份相同的文件.BAT
for /r %a in (.) do xcopy /y c:\1.txt "%~pa"
---------- 一張圖片一次復(fù)制幾十張.BAT
@echo off
for /l %a in (1, 1, 10) do copy "a.jpg" "a%a.jpg"
---------- 自動(dòng)為備份的目標(biāo)文件命不同的名稱.BAT
echo f | xcopy x.x 目標(biāo)路徑\"%date%-x".x
想要做到即使目標(biāo)文件與源文件相同,也要備份一份,應(yīng)怎樣做?例如,今天的目標(biāo)文件為2004-02-07-00001.ZIP,明天的目標(biāo)文件為2004-02-08-00001.ZIP以此類推.可以留幾十個(gè)備份且文件名會(huì)自動(dòng)更正,有沒有辦法?
---------- 列表文本文件文件名+文件內(nèi)容.BAT
find /v "" *.* >1.txt
path c:\mysql\bin;c:\progra~1\winrardel /q/f d:\bakup\*.*@echo off mysql -uroot -ppassword dbname < sql_out_cmd.sql @echo onfor /F "tokens=1,10" %%i in ('date /T') do rar a -m1 -r -o+ d:\bakdir_rar\%%i.rar d:\bakup\*.*