Output Nth BAT variable (AlLeesno)

xiaoxiao2021-03-06  20

Term: freexploit

Author: AlLeesno

Date: 2005-3-25

HHHHHK: I am writing a batch, FOR / R% PATH %% K in (% filetype%) do [cmd] I now want to express the third %% K variable, how is it? First come to see an example

Quote

FOR / R% K IN (* .exe) Do @echo% ki: / test> for / R% k in (* .exe) do @echo% ki: /test/6.exei: / test / all / sadsad .exei: /test/bug/okok.exe

This command is used to traverse the current directory and the subdirectory output all the absolute paths suffixed by exe.

Quote

If we want to output the third variable, it is i: /test/bug/okok.exe We can temporarily enter the information to the temporary file and then extract for / R% K in (* .exe) do @echo% k> > AlLyleNo.TMP then extract for / f "Skip = 2"% I in (AlLfeesno.tmp) do @echo% I Since FOR / R% K in (* .exe) Do @echo% k >> AllySno.TMP The save result is to save in line, so we use FOR / F "SKIP = 2"% I in (AllySno.tmp) Do @echo% I Skip parameters to skip line jump 2 lines After taking the third line, the output is us The result of the desired result output the third variable

Quote

Several fewer questions 1 SKIP <= 0 When the program is wrong, it is necessary to join the fault tolerance parameter 2 If you just need to display a third line, not the three-line and the latter program cannot use tokens to filter the display without display. Why? Because tokens only supports 26 tokens when the input result is greater than 26, it is not a matter of fact that TOKENS is also quite troubles. So another very simple method 3 is used in the following program 3 When the variable that needs to be output is greater than the actual number of lines When the output is empty, it is best to join the fault tolerance prompt 4 Remember to detect allyeesno.tmp This temporary file because we use >> to output the test results to the temporary file >> is added, so you must check the directory is existing. Allyesno.tmp Temporary File 5% i and %% i This carefully watching Windows Help will know that when we are writing in BAT is %% i and the writing of the command line should be a% I6 may have problems due to everyone The environment variable of CMD may be changed to the registry to cause the BAT run uncommonly resolved to run the cmd.exe after entering the CMD interface. I only test only in my own machine. reference

The full program is as follows

Quote

@echo offclsrem output Nth BAT Variable By AllyESNO 2005-3-25SET Addskip = 0set count = 0if "% 1" == "" Echo plz type the filetype what you want to find & goto readmeif "% 2" == "" Echo Plz Type The Variable Number Which You Want To Output & GotmeiF Exist Allyesno.tmp Del AllySno.tmp> NulFOR / R %% K in (*.% 1) Do @echo %% K >> AllySno.tmpif Not Exist AllySno.tmp Echo Error I can't Find Anyfile & goto endfor / f %% k in (allyesno.tmp) do set / a count = count 1IF "% 2" == "all" type allyesno.tmp & gotiF% 2 gtr% count% echo god Variable number overflow! You got a shell ???? & goto endif by 2 EQU 1 for / f %% k in (AlLeesno.tmp) do if %% k == %% K @echo %% K & goto End IF% 2 Leq 0 echo you make a joke! & goto endset / a addskip =% 2-1FOR / F "SKIP =% addskip%" %% K in (allyesno.tmp) DO if %% K == %% K @echo %% K & Goto end: NV FILETYPE VARIABLE NUMBERECHO USE: NV FILETYPE ALLECHO EXAMPLE: NV EXE 3 Echo Example: NV EXE ALL: END Save the above code to nv.bat Run Example: NV EXE 3 is to find all EXE files and output The third variable result EXAMPLE: NV EXE All is a file that finds all EXE and outputs all results PS: Write this program source to HHH HHK questions

Annex nv.rar (Downloads: 0)

转载请注明原文地址:https://www.9cbs.com/read-42826.html

New Post(0)