for %var in (set) do commond
for %one in (1,2,3,4,5) do echo
-->1
-->2
-->3
-->4
-->5
for /r . %i in (.) do @echo %i >> t.txt && t.txt
##这一步生成目录文件名到文件t.txt
for /f "skip=1 delims=." %i in (t.txt) do @echo "%i" >> tar.txt
##处理上一步生成的t.txt,从中读取内容并略去第一行,将每一行加上""后输出至tar.txt。加引号处理是因为7z命令行的要求
del t.txt
for /f "delims=" %i in (tar.txt) do 7z a %i %i
##利用处理后生产的tar.txt,再利用7z命令,将文件压缩。生成的是.7z,放在了各个文件夹中
-
ren/rename TargetFileName Newname
-
7z e .\ -o.\ -pXXXXX -ssp
直接解压压缩文件中的目录,不考虑其中的组织结构而直接使其平铺解压 注意:不带-符号的需要空一格后输入参数;带-负号的不用加空格,直接写出参数
解压并保持源文件中的目录结构
设定解压后文件的存放地址为当前目录
设置解压密码为XXXXX,-p后不用带空格
使解压后的文件不带空文件夹
将当前目录下的文件设置为一个7z压缩文件
压缩完毕后删除文件
del *.txt
表示删除后缀为 .txt
的目录下文件
将 X:\Microsoft VS Code\bin
添加到系统变量 path
中
在cmd中输入 code [fileName]
cd.>fileName.fileType
echo hi there > a.txt
上面的命令总共完成了两步操作
1. 在命令行显示hi there
1. 将命令行输出的内容改变输出地点,改至./a.txt
中。既先创建./a.txt
,再将命令行输出放入其中。
如果只是想将内容添加至文件,可以使用下列命令
echo hi there again! >> a.txt
既 >>
会将输出方法改变为追加,而 >
则为覆盖。
||
前后都是命令,
- 当
||
前的命令出错后才会执行||
后的命令 - 若
||
前的命令正确执行则不会执行||
后的命令
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="cmd here"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Windows\\System32\\cmd.exe s k pushd %V"
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\ShellNew
@ECHO OFF REM.-- Prepare the Command Processor SETLOCAL ENABLEEXTENSIONS REM -- REM -- Copyright note REM -- This script is provided as is. No waranty is made, whatso ever. REM -- You may use and modify the script as you like, but keep the version history with REM -- recognition to http://www.dostips.com in it. REM -- REM Version History: REM XX.XXX YYYYMMDD Author Description SET "version=01.000" &:20051201 p.h. initial version, origin http://www.dostips.com SET "version=01.001" &:20060122 p.h. Fix missing exclamation marks in documentation (http://www.dostips.com) SET "version=01.002" &:20060218 p.h. replaced TEXTAREA with PRE XMP (http://www.dostips.com) SET "version=01.003" &:20060218 p.h. php embedding (http://www.dostips.com) SET "version=01.004" &:20060723 p.h. fix page links for FireFox (http://www.dostips.com) SET "version=01.005" &:20061015 p.h. invoke HELP via '"call" help', allows overriding help command with a help.bat file (http://www.dostips.com) SET "version=01.006" &:20061015 p.h. cleanup progress indicator (http://www.dostips.com) SET "version=01.007" &:20080316 p.h. use codepage 1252 to support european users (http://www.dostips.com) SET "version=02.000" &:20080316 p.h. use FOR command to generate HTML, avoids most escape characters (http://www.dostips.com) SET "version=02.000" &:20100201 p.h. now using css and xhtml REM !! For a new version entry, copy the last entry down and modify Date, Author and Description SET "version=%version: =%" for /f "delims=: tokens=2" %%a in ('chcp') do set "restore_codepage=%%a" chcp 1252>NUL set "z=%~dpn0.htm" rem echo.^> >"%z%" echo.^> >"%z%" set "title=DOS Command Index" for /f "tokens=*" %%a in ('ver') do set "winver=%%a" echo.Creating the header ... for %%A in ( "" "" "" "
%title% " "" "" "" "" "%title%
" "" "" "" "
" "" " Windows Version : %winver% " " Document Source : " " http://www.dostips.com
" " http://www.dostips.com/%~nx0.php" "" " Created by : " " %~nx0
Source Code below
" "" ) do echo.%%~A>>"%z%" echo.Creating the index ... set /a cnt=0 for /f "tokens=1,*" %%a in ('"help|findstr /v /b /c:" " /c:"For more""') do ( for %%A in ( "
" "" ) do echo.%%~A>>"%z%" set /a cnt+=1 ) for %%A in ( " %%a %%b
" ) do echo.%%~A>>"%z%" echo.Extracting HELP text ... call:initProgress cnt for /f %%a in ('"help|findstr /v /b /c:" " /c:"For more""') do ( echo.Processing %%a for %%A in ( "TOP" "%%a
" "" ) do echo.%%~A>>"%z%" call help %%a >>"%z%" 2>&1 echo ( >>"%z%" for %%A in ( " "
) do echo.%%~A>>"%z%"
call:tickProgress
)echo.Injecting source script ...
for %%A in (
""
""
""
"TOP"
"DOS Batch Script Source that created this Document
"
"This %title% has been created automatically by the following DOS batch script:"
""
""
"" ) do echo.%%~A>>"%z%" type "%~f0" >>"%z%" echo.Creating the footer ... echo ( >>"%z%" for %%A in ( " "
"
""
"
""
""
) do echo.%%~A>>"%z%"chcp %restore_codepage%>NUL
explorer "%z%":SKIP
REM.-- End of application
FOR /l %%a in (5,-1,1) do (TITLE %title% -- closing in %%as&ping -n 2 -w 1 127.0.0.1>NUL)
TITLE Press any key to close the application&ECHO.&GOTO:EOF::-----------------------------------------------------------
::helper functions follow below here
::-----------------------------------------------------------:initProgress -- initialize an internal progress counter and display the progress in percent
:: -- %~1: in - progress counter maximum, equal to 100 percent
:: -- %~2: in - title string formatter, default is '[P] completed.'
set /a "ProgressCnt=-1"
set /a "ProgressMax=%~1"set "ProgressFormat=%~2"
if "%ProgressFormat%"=="" set "ProgressFormat=[PPPP]"
set "ProgressFormat=%ProgressFormat:[PPPP]=[P] completed.%"
call :tickProgress
GOTO:EOF:tickProgress -- display the next progress tick
set /a "ProgressCnt+=1"
SETLOCAL
set /a "per=100*ProgressCnt/ProgressMax"
set "per=%per%%%"
call title %%ProgressFormat:[P]=%per%%%
GOTO:EOFOriginal: https://www.cnblogs.com/dysonxxxxx/p/16582115.html
Author: dysonkkk
Title: cmd学习笔记
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/578830/
转载文章受原作者版权保护。转载请注明原作者出处!