Qhov wikiHow no qhia koj yuav sau thiab khaws cov ntaub ntawv yooj yim li cas ntawm lub khoos phis tawj Windows. Cov ntaub ntawv no muaj cov lus ntawm DOS (Windows lus) cov lus txib thiab feem ntau yog tsim los kom qhib siv cov lus txib nquag, xws li xa cov ntaub ntawv. Koj tsis tas yuav rub tawm qhov program kho kom raug los tsim cov ntaub ntawv batch; Windows qhov kev pab cuam Notepad ntau dua li txaus.
Kauj ruam
Ntu 1 ntawm 2: Kawm Batch File Basics
Kauj Ruam 1. Qhib Notepad
Qhov kev pabcuam no tso cai rau koj los tsim cov cai raws li cov ntawv sau thiab khaws nws thaum ua tiav raws li cov ntawv ua. Txhawm rau nkag mus rau qhov program, mus rau cov ntawv qhia zaub mov Pib ”
ntaus Notepad, thiab nyem rau " Notepad "Hauv xiav nyob rau sab saum toj ntawm cov ntawv qhia zaub mov.
Notepad feem ntau yog siv los hloov cov ntawv cov ntawv rau hauv cov ntaub ntawv. Txawm li cas los xij, koj tuaj yeem sau cov ntawv ua cov ntawv los ntawm txhua daim ntawv thov
Kawm qee qhov yooj yim batch ua cov ntawv txib. Batch cov ntaub ntawv tuaj yeem ua haujlwm ntawm DOS cov lus txib. Qhov no txhais tau tias cov lus txib koj siv yog zoo ib yam li DOS hais kom ua. Qee qhov lus txib tseem ceeb suav nrog:
- ECHO - Qhia cov ntawv ntawm qhov screen
- @ECHO OFF - Hides ib txwm pom cov ntawv
- START - Khiav cov ntaub ntawv los ntawm daim ntawv thov tseem ceeb
- REM - Ntxig kab lus tawm tswv yim hauv qhov program
- MKDIR/RMDIR - Tsim thiab tshem tawm cov npe
- DEL - Rho tawm cov ntaub ntawv (ib leeg lossis ntau)
- COPY - Luam ib lossis ntau cov ntaub ntawv
- XCOPY - Tso cai rau koj luam cov ntawv nrog xaiv ntxiv
- FOR/IN/DO - Tso cai rau koj xaiv lossis qhia meej cov ntaub ntawv.
- TITLE- Kho lub npe ntawm qhov program program window.
Sau cov npe tsim cov haujlwm. Ib txoj hauv kev yooj yim tshaj plaws los kawm tsim cov ntaub ntawv batch yog tsom mus rau cov lus txib lossis cov haujlwm ua ntej. Piv txwv li, koj tuaj yeem siv cov ntawv batch kom sai tsim ntau cov npe:
MKDIR c: / example1 MKDIR c: / example2
Sau cov cai los tsim cov phiaj xwm thaub qab yooj yim. Batch cov ntaub ntawv yog qhov nruab nrab zoo rau kev khiav ntau cov lus txib, tshwj xeeb tshaj yog tias koj tau teeb tsa lawv kom khiav ntau zaus. Nrog XCOPY cov lus txib, koj tuaj yeem tsim cov ntaub ntawv uas luam cov ntawv los ntawm cov ntawv xaiv rau hauv daim nplaub tshev uas tau khaws cia, thiab tsuas yog sau cov ntaub ntawv uas tau hloov kho txij li qhov kev sib tham zaum kawg:
@ECHO OFF XCOPY c: / thawj c: / backup nplaub tshev /m /e /y
Cov lus txib no ua haujlwm los theej cov ntaub ntawv los ntawm "thawj" nplaub tshev rau "thaub qab" nplaub tshev. Koj tuaj yeem hloov daim nplaub tshev nrog qhov chaw nyob ntawm cov ntawv xav tau lossis cov npe. "/M" qhia tias tsuas yog cov ntaub ntawv hloov tshiab yuav tau theej, "/e" qhia tias txhua qhov chaw nyob hauv cov npe xaiv yuav raug theej, thiab "/y" qhia cov lus lees paub thaum twg cov ntaub ntawv qub rov sau dua los ntawm cov ntawv tshiab
Sau cov txheej txheem thaub qab ntau dua. Tsim cov ntawv uas ua haujlwm rau luam cov ntaub ntawv los ntawm ib daim ntawv mus rau lwm qhov yog qhov lom zem tiag. Txawm li cas los xij, yuav ua li cas yog tias koj xav ua qhov kev cais tib lub sijhawm? Rau cov xwm txheej zoo li no, FOR/IN/DO hais kom ua yuav pab tau heev. Koj tuaj yeem siv cov lus txib no los qhia lossis qhia qhov twg xa/theej cov ntaub ntawv raws li lawv txuas ntxiv mus:
@ECHO OFF cd c: / REM sources Qhov no yog qhov chaw ntawm cov ntaub ntawv los txheeb rau %% f IN (*.doc *.txt) Ua XCOPY c: / source / "%% f" c: / text /m /y REM Cov lus txib no txav cov ntaub ntawv nrog qhov txuas ntxiv.doc lossis REM.txt los ntawm c: / cov ntaub ntawv nplaub tshev rau c: / ntawv nplaub tshev REM %% f yog qhov sib txawv rau %% f IN (*.jpg *.png *.bmp) Ua XCOPY C: / source / "%% f" c: / images /m /y REM Cov lus txib no txav cov ntaub ntawv nrog qhov txuas ntxiv.jpg,.png, REM lossis.bmp los ntawm c: / source nplaub tshev rau c: / duab nplaub tshev
Sim nrog ntau cov lus txib sib txawv. Yog tias koj xav tau kev tshoov siab, koj tuaj yeem saib cov ntawv piv txwv hauv internet.
Ntu 2 ntawm 2: Txuag Cov Ntaub Ntawv Batch
Kauj Ruam 1. Ua kom tiav cov ntawv sau
Tom qab ua tiav thiab tshawb xyuas cov lus hais kom ua, koj tuaj yeem txuag nws ua cov ntawv ua tiav.
Kauj Ruam 2. Nyem Cov Ntaub Ntawv
Nws nyob rau sab saud sab laug ntawm lub qhov rai "Notepad". Cov ntawv qhia zaub mov nco-down yuav tshwm tom qab ntawd.
Kauj Ruam 3. Nyem Txuag Raws Li…
Qhov kev xaiv no yog nyob hauv cov ntawv qhia zaub mov nco-down " Cov ntaub ntawv " Thaum nyem, lub qhov rai "Txuag Raws Li" yuav tshwm.
Kauj Ruam 4. Sau lub npe ntaub ntawv thiab txuas ntxiv ".bat"
Hauv "Cov ntaub ntawv npe" teb, ntaus lub npe ntawm qhov haujlwm koj xav tau, ua raws los ntawm.bat txuas ntxiv.
Rau qhov program hu ua "Backup," piv txwv li, ntaus Backup.bat rau hauv daim teb no
Kauj Ruam 5. Nyem rau lub npov "Txuag raws li hom"
Lub npov no nyob hauv qab ntawm qhov "Save As" window. Cov ntawv qhia zaub mov nco-down yuav tshwm.
Kauj Ruam 6. Nyem Rau Txhua Cov Ntaub Ntawv
Qhov kev xaiv no yog nyob hauv cov ntawv qhia zaub mov nco-down. Nrog rau qhov kev xaiv no, cov ntaub ntawv tuaj yeem raug cawm raws li kev txuas ntxiv uas koj tau hais tseg (hauv qhov no, ".bat").
Kauj Ruam 7. Xaiv qhov chaw txuag
Nyem ib daim nplaub tshev nyob rau sab laug ntawm lub qhov rais (piv txwv li " Duab ") Los xaiv qhov chaw nyob.
Kauj Ruam 8. Nyem Txuag
Nws nyob hauv kaum sab xis-sab xis ntawm "Save As" window. Qhov rai yuav kaw tom qab ntawd.
Kauj Ruam 9. Kaw cov ntawv Notepad
Cov ntaub ntawv yuav raug khaws tseg ua cov ntaub ntawv batch hauv qhov chaw xaiv.
Kauj ruam 10. Kho kom raug cov ntsiab lus ntawm cov ntaub ntawv batch
Thaum twg xav tau, koj tuaj yeem nyem rau ntawm cov ntawv thiab xaiv " Kho kom raug "Los ntawm cov ntawv qhia zaub mov nco-down. Tom qab ntawv, cov ntawv yuav raug qhib ua Notepad daim ntawv. Txij ntawm no mus, koj tuaj yeem hloov pauv thiab khaws cov ntaub ntawv los ntawm nias lub keyboard shortcut Ctrl+S.
Cov kev hloov pauv yuav pib siv tam sim ntawd thaum koj khiav cov ntawv
Lub tswv yim
- Koj yuav tsum siv cov cim hais yog tias koj xav siv phau ntawv teev npe lossis cov ntaub ntawv uas muaj chaw nyob hauv lawv cov npe xws li pib "C: / Cov ntaub ntawv thiab teeb tsa \").
- Koj tuaj yeem siv tus thib peb cov ntawv kho qhov program xws li Notepad ++ txhawm rau kho cov ntaub ntawv ntau yam, tab sis feem ntau siv cov haujlwm zoo li no yog pov tseg lub sijhawm yog tias koj tsuas yog xav sau cov ntawv yooj yim.
- Qee cov lus txib (piv txwv li ipconfig) xav tau kev tso cai ua haujlwm los khiav. Koj tuaj yeem nyem qhov ntawv thiab xaiv "Run as Administrator" los tso cai tso cai tsuav yog koj siv tus thawj tswj hwm tus account.