![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-08 20:14 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| WinPE、PowerShell及其它命令行系统专区 » CMD [Learning] |
| Printable Version 17,479 / 48 |
| Floor1 plp626 | Posted 2008-01-28 10:01 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
The tutorial will be continuously updated and supplemented later. Newcomers are kindly expected. You are also welcome to join. plp626 is willing to discuss and share with you if there are new discoveries. Blog--Study Notes -------Suitable for those with certain foundation--------- ~~~~~~~~~~~~~Pleaseguysdonotpostwaterposts! Can-----> Put forward suggestions and opinions. Can-----> Criticize! Welcome-----> Point out mistakes!!! ~~~~~~~~~~~~~Thankyou! Declaration: I can't say that all the codes in this post are original, but when citing, be sure to note from cn-dos.net There are 71 built-in commands in cmd under Windows XP. Each command has its own help information. Now, first export all these helps to the cmdhelp directory on the desktop. Here is a code: I still recommend reading the original English help. This combines the English version with the Chinese version. If your English is a bit poor, you can read them together. I originally wanted to make it in htm format. I haven't figured it out yet. There are already people in the forum who have written relevant codes. You can search and refer to them to modify. (P.S.: The relevant code has been given by ZJHJ on floor 17, you can refer to it) The following post is what I wrote while learning. I will add more if I gain something, so modifications are inevitable. Some of the usages may not be explained in the help. These are mostly summarized by me from the predecessors in the forum. Graspvariableinterception%str:~x,y% means: The offset of %str% is at position x, and the length is y characters. ~~~~~~~~~plp626 on 2008-1-28 ~~~~~~~~~~ start──────────────────────────────────────────────── Often need to use variable interception, so this command must be mastered proficiently. Here, x and y are positive and negative. There are a total of 4 situations. How are they intercepted respectively? Do a small test, demonstrate the results at the command prompt: This display result means that the value of variable %str% is "2008-01-28 星期一" This means that starting from the right side of the 2nd character of %str%, intercept 4 characters backward. The value of variable %a% is this. The same below. Starting from the right side of the 6th character of %str%, intercept the remaining characters after discarding the last 2 characters of %str%. The value of variable %b% is this. Starting from the left side of the 3rd character from the end of %str%, intercept 2 characters backward. The value of variable %c% is this. Starting from the left side of the 6th character from the end of %str%, intercept the remaining characters after discarding the last 2 characters of %str%. The value of variable %d% is this. ------------------------------------------------------------------------------------------------------------------------------- It is inconvenient to remember the above 4 situations. The important thing is to grasp the commonality. The following is my understanding (very unprofessional! Because I am not a computer major): Observe the above 4 assignment statements and summarize to get the statement set s=%str:~x,y% The function is: Intercept characters with length y at offset x of string %str%, and assign to variable s. Understanding and mastering: Remember: Left->Right --- positive direction Right->Left --- negative direction When x is positive or 0, offset x means the right side of the x-th character along the positive direction. When x is negative, offset x means the left side of the x-th character along the negative direction. For example, the offset at -4 of abcdefg is the left side of character d. When y is positive or 0, intercepting "length" y characters means obtaining y characters along the positive direction. When y is negative, intercepting "length" y characters means discarding |y| (absolute value of y) characters along the negative direction and getting the remaining characters. For example, The offset at -4 of abcdefg, intercepting characters with length 2, is the left side of character d, and obtaining 2 characters along the positive direction is "de" The offset at 2 of abcdefg, intercepting characters with length -4, is the right side of character b, and discarding 4 characters along the negative direction gets the remaining character "c" In addition: When y is negative, %str:~y% means obtaining the last |y| characters of %str% (this can be regarded as a short form of %str:~-|y|,|y|%) When y is positive, %str:~y% means discarding the first y characters of %str% and getting the remaining characters (this is very important, which cannot be expressed by the method of offset + length.) About the short form: When one of x or y is 0, 0 can be omitted. For example: %str:~0,3% can be abbreviated as %str:~,3% When x is positive: %str:~-x,x'% can be abbreviated as %str:~-x% (here x' is any positive number greater than x) Finally, it should be noted that an unreasonable interception will get an "empty" value. For example, now execute set str=abcde set f=%str:~-2,y% Obviously, the offset -2 of %str% is the left side of character "d". Since no matter what y is, the obtained string is a subset of the remaining string "de", so to make %f% not empty, reasonable interception is required. When y takes 0, ±1, 2, etc., %f% is not empty; when y is less than or equal to -2, %f% is empty; when y is greater than or equal to 2, %f% is always "de". ─────────────────────────────────────────────────end In addition: Environment variable replacement has the following enhancements: For example, execute: It will display: 1+34561+3456 2345623456 <1>. Very important set command set has two parameters /a and /p Typing "set" directly will display the system environment variables and current environment variables. Typing "set p" will display all variables starting with letter P. No need to say more about the default parameters. Note two points: 1. Assign empty value: set "a=" 2. Develop a good habit to avoid mistakenly assigning an extra space. For example: set str=abc Add a pair of double quotes: set "str=abc" For /a parameter /A command line switch specifies that the string to the right of the equal sign is an evaluated numeric expression. The evaluator is simple and supports the following operations in decreasing order of priority: Note the premise: 1. Octal number 0? (0<=?<=7) and hexadecimal number 0x? (0<=?<=15). Those not starting with 0 are decimal numbers. 2. The /a parameter only operates on integers from -(2^31-1) to 2^31 (note that it is the XP version). This can be tested with code: Unary operators ~ ! - ~ Take complement Regard -(2^31-1) to 2^31 as a number axis, with "origin O" at the right side of 0 and the left side of -1. (This number axis can be regarded as a closed number axis at both ends. Adding 1 to 2^31-1 will get -2^31) In this way, the complement of a binary number (all integers) in the computer can be regarded as finding the "opposite number": -2^31 ...︺︺︺︺︺︺︺︺︺︺︺︺︺︺︺O︺︺︺︺︺︺︺︺︺︺︺︺︺︺︺... 2^31-1 ... -3 -2 -1 0 1 2 3 ... ~ means the opposite number of For example: %a% is equal to 0 %a% is equal to -6 ! Take NOT ! is 0 ! is 1 For example: %a% is equal to 0 %a% is equal to 1 "-" Take negative number - is consistent with -x in mathematics, but pay attention to the situation when overflow occurs. For example: %a% is -2147483648 instead of 2147483648, because 2147483648 has overflowed: 2147483648=(2^31-1)+1 Arithmetic operators * / % ﹢ - Arithmetic operators: * / % ﹢ - correspond to Mathematical symbols: x ÷ mod(remainder) + - Need to note that "%" is at the command line, while in bat, it should be written as %% Logical shift: << >> Note that in batch processing or command line, add a pair of double quotes "" or escape <,> with ^. set /a "<<" Means shift the binary number of left by bits For example: %a% is equal to 30 This is because: 15=bin(00 00000 00000 00000 00000 00000 01111) Shifting left by 1 bit becomes bin(0 00000 00000 00000 00000 00000 011110) And bin(0 00000 00000 00000 00000 00000 011110)=2^4+2^3+2^2+2^1=30 After simple mathematical derivation, it can be known that: "<<"==*2^ ">>"==/2^(note overflow) Similarly, ">>" is right shift, the principle is the same, which is omitted here. Logical "XOR", "OR", "AND": "^", "|", "&" Note that in batch processing or command line, add ^ before the operator. Here: ^ | & correspond to In discrete mathematics: XOR⊕ Disjunction∨ Conjunction∧ Rules: Conjunction∧(if there is 0, it is 0) Disjunction∨ (if there is 1, it is 1) XOR⊕ (same is 0, different is 1) For example: %a% is equal to 10 This is because: 01111 ⊕) 00101 ───── =) 01010 And bin(01010)=10 For "|", "&" the principle is the same, which is omitted here. Assignment operator "=" needs no explanation. For *= /= %= += -= &= ^= |= <<= >> Take "+=" as an example, the same for others. This is just a shorthand. For example, the following two lines of code are equivalent: Expression separator "," This operator can be used to simplify code: For example: It can be abbreviated as: Find the decimal part of a fraction Example: Calculate the 100th decimal place of 7/5: call:div 7 5 100 ans In addition: set /a ... and set /p ... You can omit the space between set and / and write it as set/a ... and set/p ... There are many such usages that omit spaces, which will be supplemented later. Pointer usage of set/a (called pointer for now): Numerical definition: Count the number of occurrences of various characters in a string: About parameter /P set/p has two usages: 1. Receive keyboard input Note that the characters that can be used as variables cannot be constant numbers, but can be letters, Chinese characters, etc., and their strings. When entering special characters ^&|<>,add ^ in front, otherwise a syntax error occurs. The statement "SET /p a=Please enter a string:" Similar to c++: 2. Receive the first line of a file. This can be understood with the following two codes. %0 means the batch processing itself: Code 1: Code 2: 3. Special usage of set/p . Left alignment (note that the tab in the code is): Delay to delete the carriage return character (can also use ping) to display: Delete the carriage return character of each line in 1.txt and output to 2.txt (into one line): Generally, this usage of set /p will be related to | or <nul. <nul makes the last character of the output not have a newline character, which is very useful. [ Last edited by plp626 on 2009-4-24 at 05:00 ] |
|
| Floor2 plp626 | Posted 2008-01-28 10:05 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<2].for CommandDetailExplanation
start──────────────────────────────────────────────── FOR path] %variable IN (set) DO command 1. Default Parameters for %i in (cn dos 5 2 1 ! ??.* cmd\*) do echo %i //Print the strings in turn: cn, dos, 5, 2, 1, "The full name of non-hidden files matching ??.* in the current path", "The full name of non-hidden files in the cmd directory in the current path". The elements are delimited by spaces here. //For the characters? * these two, for will match the file name as a wildcard, and will not display these two characters 2. Parameter d is the abbreviation of directory. The function is that when there are wildcards in the set, it matches the directory name instead of the file name. for /d %a in (cn dos 5 2 1 ! * cmd\*) do echo %a //Print cn, dos, 5, 2, 1, !, "The directory name of all non-hidden directories in the current path", "The directory name of all non-hidden directories in the cmd directory in the current path" in turn 3. Parameter r is the abbreviation of road. The function is that it will add the directory tree (note that the directory tree includes hidden directories and subdirectories) of the specified path to the elements in the set and then print for /r %windir% %i in (plp626 . *) do echo %i //Print in turn "%directory tree of %windir%\plp626" "%directory tree of %windir%\." "The full name of the corresponding file in the directory tree of %windir% (note that the files in the corresponding directory do not have the hidden attribute!)" //When %windir% is omitted, it defaults to the current path. 4. Parameter l is the abbreviation of ladder. The function is to loop in the way of "start step end" progression. These three elements must be natural numbers. When the step is 0, it will become an infinite loop. for /l %a in (-10 1 10) do echo %a //Display -10 -9...10 in turn. This sentence means that the starting value is -10, increasing by 1 step, and the loop ends when it increases to 10 5. Parameter f This is very important. Look carefully. f is the abbreviation of file. Different from other parameters, this one parameter has 3 usages, each of which is very powerful: 5.1 The elements of the set are file names for /f "eol=; skip=3 tokens=2,3* delims=, " %a in (test_1.txt test_2.txt) do echo %a %b %c //It will analyze each line in test_1.txt test_2.txt in turn, ignore those lines starting with semicolon (eolith original, starting), skip (skip) the first 3 lines Use "," as the delimiter (delimit), and display the 2nd, 3rd, and remaining strings (token marks). 5.2 The elements of the set are the output results of external commands for /f "delims=" %a in ('more test.txt') do echo %a //Cancel the default delimiter (space) to analyze the results printed by more test.txt line by line, and spaces will also become valid strings. for /f "tokens=*" %a in ('more test.txt') do echo %a //Analyze the results printed by more test.txt line by line. Since the default delimiter is space at this time, the space characters at the beginning of the line will not be displayed. //Please pay attention to this pair of single quotes in the parentheses. It has the meaning of execution. The output of the execution object is used as a "file" for analysis, which determines that the output of the object must be written to memory. If it is not like this, for example, change more test.txt to start test.txt or test.txt, it will open test.txt, and %a does not receive the return character command,.... //In addition, this external command also supports compound sentences, such as: for /f %%a in ('if exist 1.txt ^(echo ++^) else echo -- ')do echo %%a 5.3 The elements of the set are strings for /f "tokens=*" %a in (" cn dos 帅 !") do echo %a for /f "delims=" %a in (" cn dos 帅 !") do echo %a //Both of these two sentences will display cn dos 帅 ! but the difference is that the former skips the space before cn, and the latter prints it as it is. For 5.1, if there is a test 3.txt (the file name is test 3), that is, the file name contains spaces, you need to enclose it with double quotes to indicate that the file name is correctly interpreted. But this becomes the string usage of 5.3. For the interpreter to interpret correctly, it is a file name, not a string. You need to use the keyword "usebakeq". The following sentence displays the relevant content of the file test 3.txt (the default delimiter is space), and the interpreter will treat test 3.txt as a file name, not a string. for /f "usebackq" %i IN ("test 3.txt") DO echo %i Sometimes you need to judge the mobile hard disk or USB flash drive, use this command 6. Expansion of for Variables Take "test.bat" in the path C:\Documents and Settings\pp365\Desktop\ as an example, and test the for statement variables as follows (Here, %0 is used as an example, and the corresponding variable can be substituted for 0 in the for statement): Get the full path of this batch file with double quotes using percent 0:──────────────────────────────────────────────end [ Last edited by plp626 on 2008-3-23 at 10:53 PM ] |
|
| Floor3 plp626 | Posted 2008-01-28 12:49 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<3>. Skilled in mastering CALL start
call------"Pass" in a single process start-----Start a new process. Using call to intercept variables: call has a secondary preprocessing function, which originates from its function call function (personal humble opinion). Because %v:~%x%,%y%% will preprocess %, for example, directly %v:~%x%,%y%% leaves the outermost pair of %, which makes us think of using call to further preprocess and read. call :label "parameter 1" "parameter 2" ... From : to the first space encountered, regarded as the end of the label. (The label can be used as the %0 parameter, that is, the spaces before and after the label will be regarded as parameter separators.) call :^^^.... will be an empty statement. The characters after & (not ^&) in the main label are executed as statements. After execution, it jumps to the sub-label. If one of the five characters &|><: is contained in the sub-label, the characters after it are regarded as comments and will not be explained. The label characters cannot be a single <space> &()^=;%+,:|, but the following special characters as labels are legal: `, ' ,^^ , ^^& , "<space>" , " , "", @,,{,},?,/,\,*,-,$,#,~,., When delayed environment variables are enabled,! cannot be used as a label. Chinese characters, other extended characters, and mixed characters can also be used as labels. Although it is not recommended to use these special characters as labels, they can implement some scripts that are difficult to implement by general methods. There are up to 9 parameters. If there are more, you need to use the "shift" command (see later) call follows the following rules when jumping to the label: 1, Case-insensitive, 2, Look for it after the call statement first, and look for it before if not found later. 3, Only the first label found is executed when there are multiple identical labels. Summarize these three points into one sentence: , case-insensitive, first later then before, execute once. In addition A.bat file If you want to execute task a, you can call it like this in B.bat file (if it is in the command line, you can omit call) Here, when running B.bat under non-command line, the call in B.bat is necessary. If it is called directly in the command line as B.bat, the call in B.bat can be omitted. Template: [ Last edited by plp626 on 2008-4-16 at 11:32 AM ] |
|
| Floor4 plp626 | Posted 2008-01-29 08:20 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<4. Usage of if...else...
if condition? command A if condition? (command A) else command B EQU - equals NEQ - not equals LSS - less than LEQ - less than or equal to GTR - greater than GEQ - greater than or equal to == is different from equ. When command A is an assignment statement and the condition? is?==?, then equ should be used. Note the variable assignment within the compound statement. [ Last edited by plp626 on 2008-3-14 at 03:05 PM ] |
|
| Floor5 plp626 | Posted 2008-01-29 08:21 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
### <5>. Finding Commands find & findstr
#### find Searches for a text string in a file or files. FIND ] "string" filename] /V Displays all lines NOT containing the specified string. /C Displays only the count of lines containing the string. /N Displays line numbers with the displayed lines. /I Ignores the case of characters when searching for the string. /OFF Do not skip files with offline attribute set. "string" Specifies the text string to find. filename Specifies a file or files to search. If a path is not specified, FIND searches the text typed at the prompt or piped from another command. If no path is specified, FIND searches the text typed or piped from another command. When using find "?" file, the result will always have a line at the beginning like (indicating that the following content is from *.* this file) ---------- *.* When the /v and /c parameters are used together, it is (n is an integer) ---------- *.*: n Now, let's talk about the usage of parameters: /v parameter: lines not containing "str" As the help says, it displays lines that do not contain the specified string. find /v "?" ... displays lines that do not contain "?". But commonly used is find /v "" ... It prints all the content of the file because the file does not contain empty characters. /c parameter: count the number of lines It does not display the content, only displays the number of lines containing the search string. Here, it is necessary to understand that when find analyzes a file, it takes the carriage return and line feed characters as markers to determine the end of one line and the start of the next line. find /c "?"... does not display lines containing "?", but displays the number of lines containing "?". find /c /v "?" ... does not display the content of the lines, but displays the number of lines that do not contain "?". find /c /v "" ... only displays the number of lines that do not contain empty characters, that is, the total number of lines in the file. /n parameter: number of lines If it displays the content of the lines, it adds the line number at the beginning of the line. The /n is always effective only when used together with /v, and is invalid when used together with the /c parameter. /i parameter: Ignores case for "?" If "string" contains spaces, the spaces will not be interpreted as logical OR, but as a valid string. find parameter "?" *.txt *.c searches in all txt files in the current path according to (files can also be in enumerated format: 1.txt 2.txt 3.txt) Common formats: find /c "?" *.txt *.bat find /v "?" *.txt *.bat find /n "?" 1.txt find /c /v "" *.* #### findstr FINDSTR ] strings filename] /B Matches pattern if at the beginning of a line. /E Matches pattern if at the end of a line. /L Uses search strings literally. /R Uses search strings as regular expressions. /S Searches for matching files in the current directory and all subdirectories. /I Specifies that the search is not to be case-sensitive. /X Prints lines that match exactly. /V Prints only lines that do not contain a match. /N Prints the line number before each line that matches. /M Prints only the filename if a file contains a match. /O Prints character offset before each matching line. /P Skip files with non-printable characters. /OFF Do not skip files with offline attribute set. /A:attr Specifies color attribute with two hex digits. See "color /?" /F:file Reads file list from the specified file(/ stands for console). /C:string Uses specified string as a literal search string. /G:file Gets search strings from the specified file(/ stands for console). /D:dir Search a semicolon delimited list of directories strings Text to be searched for. filename Specifies a file or files to search. Use spaces to separate multiple search strings unless the argument is prefixed with /C. For example, 'FINDSTR "hello there" x.y' searches for "hello" or "there" in file x.y. 'FINDSTR /C:"hello there" x.y' searches for "hello there" in file x.y. Regular expression quick reference: . Wildcard: any character * Repeat: zero or more occurances of previous character or class ^ Line position: beginning of line $ Line position: end of line Character class: any one character in set Inverse class: any one character not in set Range: any characters within the specified range \x Escape: literal use of metacharacter x \<xyz Word position: beginning of word xyz\> Word position: end of word For full information on FINDSTR regular expressions refer to the online Command Reference. The maximum number of bytes for the search string is 127. Examples of general expressions: 1. findstr . 2.txt or findstr "." 2.txt Find any characters (including spaces) from file 2.txt, excluding empty characters or empty lines (filters empty lines). This usage is also valid for Unicode characters, the same below. 2. findstr .* 2.txt or findstr ".*" 2.txt Find any characters including empty lines from file 2.txt (prints as is). 3. findstr "" 2.txt Find strings or lines including numbers 0-9 from file 2.txt. 4. findstr "" 2.txt Find strings or lines including any of the 52 English letters from file 2.txt. 5. findstr "" 2.txt Find strings or lines including letters a, b, c, e, z, y from file 2.txt. 6. findstr "" 2.txt Find strings including lowercase characters a-f and l-z from file 2.txt, but not including letters g, h, I, j, k. 7. findstr "MY" 2.txt Can match MahY, MbiY, MahY, etc. in file 2.txt. 8. Application of ^ and $ symbols ^ means the beginning of a line, "^step" only matches the first word in "step hello world". $ means the end of a line, "step$" only matches the last word in "hello world step". 9. finstr "" 2.txt Any character not in the character set 0-9, that is, if there is a character not belonging to 0-9, it is printed. For example, dfd41210's other 45, etc. will be printed; while 54545158 will not be printed. 10. findstr "" 2.txt Any character not in the character set a-z, that is, if there is a character not belonging to a-z, it is printed. For example, adfdfd2225 dfdfdfdfd 大富大贵, etc. will be printed; while dfdfdffd will not be printed. 11. The role of the * sign As mentioned earlier, ".*" means the search condition is any character. The * sign in the regular expression does not mean any character, but means the number of repetitions of the previous character or expression. The * sign means zero or more repetitions. 12. findstr "^*$" 2.txt This matches pure numbers. ^ represents the beginning, represents numbers, * represents zero or more repetitions, and $ represents the end. For example, 234234234234. If it is 2133234kkjl234, it will be filtered out. But a single number does not match. Findstr "^*$" 2.txt This matches pure letters. For example, sdfsdfsdfsdf. If it is 213sldjfkljsdlk, it will be filtered out. If there is no * sign in the search condition, that is, the search condition is not repeated, that is, , it can only match the first character of the string, and only this one character. Because of the restrictions of the beginning and end of the line, "^$" will match if the first character is a number, and filter out if it is not. If the string is 9, it matches; if it is 98 or 9j, etc., it does not. 13. The role of the "\<…\>" expression This means to accurately find a string. \<sss means the start position of the word, and sss\> means the end position of the word. echo hello world computer|findstr "\<computer\>" in this form. echo hello worldcomputer|findstr "\<computer\>" in this form does not work. It is looking for the "computer" string, so it is not possible. echo hello worldcomputer|findstr ".*computer\>" can match in this way. 14. "." means any character. findstr /rc:" 01...... " test.txt>>a1.txt findstr /rc:" 02...... " test.txt>>a2.txt 15. Find the period "." in English state. Add the escape character "\" in front of ".". set abc=abc de.f echo %abc%|findstr /c:"\." 16. Find "\" set abc=abc E:\123 1111 echo %abc%|findstr "E:\\" 17. /g usage Take each line of 1.txt as the search string and search in 2.txt. (If a line in 1.txt contains spaces, it is also regarded as a valid character and not interpreted as "or".) findstr /g:1.txt 2.txt Adding /b/e means exact match at the beginning and end of the line. findstr /b /e /g:1.t 2.t (or findstr /beg:1.t 2.t) 18. /o parameter ((echo.%str%&echo. )|findstr /o .)|findstr /c:" " Example: findstr . test.txt Filter empty lines and print. findstr .* test.txt Print as is. This is different from find /v "", the latter will add ---------- target file full name at the beginning of the result. findstr . test.txt|findstr /v /r /c:"^ * $" Filter empty lines and pure space lines and print. ------------- There is a file A.TXT. When JKLJHLL is found in it, delete the lines containing the JKLJHLL string (case-insensitive). findstr /ivc:"JKLJHLL" a.txt >b.txt [ Last edited by plp626 on 2008-4-27 at 01:55 AM ] |
|
| Floor6 plp626 | Posted 2008-01-29 08:21 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<6>.Check commands echo type more sort
[ Last edited by plp626 on 2008-3-3 at 11:15 PM ] |
|
| Floor7 plp626 | Posted 2008-01-29 08:22 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
### <7>. Access Commands dir cd
First, talk about dir (directory) Displays a list of files and subdirectories in a directory. DIR attributes]] sortorder]] timefield]] Specifies drive, directory, and/or files to list. /A Displays files with specified attributes. attributes D Directories R Read-only files H Hidden files A Files ready for archiving S System files - Prefix meaning not /B Uses bare format (no heading information or summary). /C Display the thousand separator in file sizes. This is the default. Use /-C to disable display of separator. /D Same as wide but files are list sorted by column. /L Uses lowercase. /N New long list format where filenames are on the far right. /O List by files in sorted order. sortorder N By name (alphabetic) S By size (smallest first) E By extension (alphabetic) D By date/time (oldest first) G Group directories first - Prefix to reverse order /P Pauses after each screenful of information. /Q Display the owner of the file. /S Displays files in specified directory and all subdirectories. /T Controls which time field displayed or used for sorting timefield C Creation A Last Access W Last Written /W Uses wide list format. /X This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place. /4 Displays four-digit years Switches may be preset in the DIRCMD environment variable. Override preset switches by prefixing any switch with - (hyphen)--for example, /-W. Among them, /a, /o, /t each have their own parameters (only one can be selected). /a attribute (attribute) There are 5 parameters: d (directories), r (read-only), h (hidden), a (archiving), s (system) and the negation switch "-" /o order (order) There are 5 parameters: n (name), s (size), e (extension), d (date), g (group directories) and a "reverse order" switch "-" /o:n Name priority (higher first) is generally: space!()-,._`+12...9aAbB...zZ Chinese characters are converted to pinyin initials ab...z /os File bytes: smaller first /oe Extension priority: empty (no extension) characters numbers letters Chinese characters in that order /od Earlier time first /og Priority to be determined /tc Creation date /ta Last access date /tw Last written date /t time (time) There are 3 parameters: c (creation) a (last access) w (written) In addition: dir |dir .|dir .\ /* Current path, files, directories dir ..|dir ..\ /* Previous path down,... dir \ /* Under the root directory... ----------------------------------------------------- cd .. Enter the parent directory cd\ Enter the root directory cd Display the current directory [ Last edited by plp626 on 2008-3-3 at 06:09 PM ] |
|
| Floor8 plp626 | Posted 2008-01-29 08:22 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<8>.comp and fc
....Please look forward to it... |
|
| Floor9 plp626 | Posted 2008-01-29 08:23 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<9>,File Operations Commands copy xcopy md move del rd attrib ren replace
....Stay tuned... [ Last edited by plp626 on 2008-1-29 at 09:55 AM ] |
|
| Floor10 plp626 | Posted 2008-01-29 08:23 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<10>.cmd and command
....Stay tuned.... [ Last edited by plp626 on 2008-1-29 at 09:58 AM ] |
|
| Floor11 plp626 | Posted 2008-01-29 08:23 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<11>,Explanation of CACLS and AT Scheduled Tasks
....Stay tuned... [ Last edited by plp626 on 2008-1-29 at 09:59 AM ] |
|
| Floor12 plp626 | Posted 2008-01-29 08:24 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<13>. Special characters <> / \ %! & ^ | and *.?,;
....Stay tuned... [ Last edited by plp626 on 2008-2-10 at 01:37 AM ] |
|
| Floor13 plp626 | Posted 2008-01-29 08:24 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
### <14>.prompt 与 debug)
Full screen (XP): ``` @echo off echo exit|cmd /kprompt e100 B8 12 00 CD 10 B0 03 CD 10 CD 20 $_g$_q$_|debug>nul @pause ``` [ Last edited by plp626 on 2008-3-20 at 01:49 PM ] |
|
| Floor14 plp626 | Posted 2008-01-29 08:24 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
<15>.Other built-in commands</color>
....Please look forward to it... |
|
| Floor15 plp626 | Posted 2008-01-29 08:25 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
Calculate the difference between two time points
Colorful character output function One - sentence hiding: code 1: @if %1* neq 0* mshta vbscript:createobject("wscript.shell").run("%~s0 0",0)(window.close)&exit code 2: @if %1* neq 0* (goto c) else mshta vbscript:createobject("wscript.shell").run("%~s0 0",0)(window.close)&exit code 3:(This is the shortest, hehe, my code) @if exist .vbs (del .vbs) else echo createobject("wscript.shell").run "%~s0",0 >.vbs&.vbs&exit Hidden call: ---------------------------------------------------------- I don't know how much enthusiasm there is left, it's almost there... Hehe After half a year, I have learned some things. While there is still enthusiasm now, I share these good methods I think with everyone, which is a return to everyone. Unfortunately, I still only know bat from start to finish. Some usages of call In the collection of for, compound statements are also supported: You might as well replace if with for and find out. Recursive usage of call Usage of start The first line of this statement "if not %1.==. call%*&exit" I often use it in many codes, and the position has been solidified. It makes the code much more readable and also much simpler. I know a little about vbs. The following code contains the idea of mixed programming, and the batch processing skills should not be underestimated: Multi - process: (I don't know what these two codes can explain) If your computer is a 10-core one: Communication between multi-processes Now the method of using temporary files is still reliable. I haven't tried the method of modifying the system environment variables such as date. In addition, the method of using exit/b?(? is a number from 0 to 9) and then using errorlevel to determine which sub-process exits can play this role in simple cases. A process "pause" (actually it is still in the execution state, just the execution pause command pauses), another process is in the execution state. If when this process also pauses, no matter how high the priority of this process is, the key corresponds to the first process that executes pause. There are many usages of call, mainly about parameters. You need to master setlocal well. Everyone pays more attention to the following two posts in their spare time. http://www.cn-dos.net/forum/viewthread.php?tid=38969&fpage=1 http://www.cn-dos.net/forum/viewthread.php?tid=39777&fpage=2 Share more with others and benefit a lot [ Last edited by plp626 on 2009-4-24 at 05:06 ] |
|
| 1 2 3 4 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |