Posted on 

windows命令行

教程

microsoft learn

[第一週] Command Line 基本指令與操作. 學習目標:學會常見指令(例如說 cd、ls、rm、mv 等等) | by MiaHsu | Medium

CHEATSHEET

名称 用法
ver Microsoft Windows [版本 10.0.19045.3803]
whoami qaq\0202qiao

dir:输出文件列表

dir | Microsoft Learn

cmd | Dir command - GeeksforGeeks

1
2
3
dir >print.txt
dir /b >print.txt #简洁模式
dir /s/b >print.txt #包含子目录
1
DIR *.*  /B >list.doc

如果你只要mp3格式的文件列表,输入的命令改为

1
DIR *.mp3  /B >list.doc

如果想生成txt格式的列表文件,输入的命令改为

1
DIR *.*  /B >list.txt

tree:输出

tree | Microsoft Learn

1
tree > list.txt

例图2

参数:

除此之外我们还有其他的参数可以设置:

命令行 效果
tree -d 只显示文件夹
tree -D 显示文件的最后修改时间
tree -L n n表示显示项目的层级,n=3即只显示项目的三层结构
tree -I pattern pattern表示想要过滤的目录,例如 tree -I “node_modules”可以过滤掉node_modules这个文件夹

注意,这里的参数-d、-D区分大小写,大家可以自行实验。

cd

cd | Microsoft Learn

  1. cd / cd \drive # 電腦最底層到根目錄:
  2. cd .. 回到上一層資料夾:
  3. cd .\ 相对路径

robocopy

多线程加快复制进度

robocopy | Microsoft Learn

RoboCopy - Ultimate Guide with Examples — LazyAdmin

findstr(待整理)

grep替代

more

翻页读取文本 | more

1
dir | more

小技巧

(CMD)start命令带空格的路径处理办法

1
start "" "D:\Program Files (x86)\Tencent\TIM\Bin\QQScLauncher.exe"

第一个参数为标题。 不管他。直接“”就可以了

网络相关

  • ping g.cn

BAT脚本编写

BAT基本语法

WINDOWS 命令行 串口 COM 发送数据

  • type con>com1 
    回车。 com1 为想发送的串口。
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    - [Connect to a device over Serial COM Port on Windows 10 with WSL1 TTY devices with Windows Terminal and minicom](https://www.hanselman.com/blog/connect-to-a-device-over-serial-com-port-on-windows-10-with-wsl1-tty-devices-with-windows-terminal-and-minicom) 通过WSL和minicom实现串口通讯

    - ```
    输入「mode」命令,并使用「com」选项指定要使用的串口号,例如:mode com3。
    使用「baud」选项指定波特率,例如:mode com3:9600。
    使用「parity」选项指定校验位,例如:mode com3:9600,n,8,1。
    使用「data」选项指定数据位,例如:mode com3:9600,n,8,1。
    使用「stop」选项指定停止位,例如:mode com3:9600,n,8,1。
    在串口连接上运行「mode」命令,您就可以通过命令行与串口设备进行通信了。
  • YaSuenag/SimpleCom: Simple serial terminal for Windows console 通过SimpleCom实现