Windows Command Line Tutorial(Windows cmd教程)

本文提供了一个Windows命令行的基本教程,包括使用/?获取命令帮助,使用Tab补全,创建和删除目录,查看磁盘信息,切换驱动器,查看和设置文件属性,以及文件的删除、重写、追加、复制、移动和重命名等操作。
摘要由CSDN通过智能技术生成

Windows Command Line Tutorial

0. A few Tips

  • Use /? to get more information

    if you want to know more about one command line order,you can type the optional “?” after the order you want to know. Then you will get the hint or the assistance.

    rmdir /?
    
  • Use Tab to get hint

    Press Tab key can help get the hint.

    • if you type “cd J”, the command match the first file with the letter ‘J’.
    • If it is not want you want ( you have many files with J letter), you can press Tab again to get the next file with ‘J’ letter.
  • Clear the Screen

    cls
    

1. Directory

1.1 Create and Remove Directories

  • make directories

    mkdir test		
    //test is the name of the directory
    
  • remove empty directory

    rmdir test
    
    • What’s notable is that the directory “test” must be empty if you want to delete it with only “rmdir” order.
  • remove non-empty directory

    rmdir /s test
    

2. Drive

if you want to know all the available drive on your computer, you can use the following order

wmic logicaldisk get name

2.1 Change Drive

if your current position is C disk and you want to move to D disk, you can type " D: " to change your drive.

C:\User\Frank>D:
  • C disk, D disk is actually a USB Drive.
  • There are also DVD drive and CD drive etc

3. File Attribute

  • see the attribute of the file

    attrib
    
    • A file can have multiple attribute at the same time. For example the file can be Read-only and Hidden.

image.png

4. Files

4.1 Delete Files

delete bacon.txt

4.2 Overwrite a file

echo helloworld > bacon.txt
  • By this order you can create the file called bacon.txt and write “helloworld” into it.

  • But if the file already exists before you echo, then your content will overwrite the original content!

4.3 Append to a file

if you just want to append some words then use >> to append

echo tunafish >> bacon.txt

4.4 Copy A file

  • copy
copy srcfile destFolder		//this is the fomat
copy test.txt TestFolder
copy test.txt d:
  • xcopy

    • if you do not add /s then only files will be copy to the destFolder
    • if you add /s then the subFolder will also be copy to the destFolder except empty ones
xcopy srcFolder destFolder /s 

4.5 Moving Files

move srcFolder destFolder

4.6 Rename Directory

rename originFolderName newFolderName
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值