1. 程式人生 > >windows常用命令(文件操作篇)

windows常用命令(文件操作篇)

bat attr 切換 統計 文件內容 重命名 st3 移動 相對路徑

  • 切換盤符:
    根目錄:
    d:
    上級目錄:
    cd  ..
    相對路徑:
    cd  test
    絕對路徑:
    cd  c:\test
    查看當前目錄:
    echo  %cd%
  • 查看文件/文件夾:
    不含隱藏文件:
    dir
    隱藏文件:
    dir  /a
    排序:
    dir  /on
  • 顯示/隱藏文件/文件夾:
    隱藏:
    attrib  +h  test
    顯示:
    attrib  -h  test
  • 創建文件:
    空文件:
    echo.  >  test.txt
    帶內容:
    echo  abc  >  test.txt
  • 創建文件夾:
    單個文件夾:
    md  test
    多個文件夾:
    md  test1  test2
    多級目錄:
    md  test1/test2/test3...
  • 復制文件:
    單個:
    copy  /y  a.txt  a.txt.back
    多個:
    copy  /y  *.txt  *.txt.back
  • 復制文件夾:
    不含隱藏文件:
    xcopy  test1  test2
    隱藏文件:
    xcopy  /h  test1  test2
  • 刪除文件:
    單個:
    del  /q  a.txt
    多個:
    del  /q  *.txt
  • 刪除文件夾:
    rd  /s  /q  test
  • 重命名文件/文件夾:
    單個:
    move  a  aa
    多個:
    ren  *.txt  *.bat
  • 移動文件/文件夾:
    move  /y  test1  test2
  • 查找/統計文件:
    顯示行號:
    find  /n  "str"  test.txt
    統計行數:
    find  /c  "str"  test.txt
    查看文件內容:
    findstr  "."  test.txt
  • windows常用命令(文件操作篇)