Windows Command Line, CMD, 命令提示字元 使用指南

2021-07-09

筆記使用 Windows Command Line, 命令提示字元,進行作業系統操作的實用指令與教學,同時逐步在 IT 的生涯基於工作需要,完成 CMD 指令大全,並且搭配 Powershell 與 bat 執行檔,自動執行程式與登入等工作。

Directory Manage 📁

刪除資料夾

rmdir /q /s tempdir

參數

用途

/q

quiet

/s

sub-directory

copy cmd (必須自行建立不存在的資料夾)

mkdir tempdir

copy .\sharepoints\*.png .\tempdir\ /q

xcopy cmd (自動建立不存在的資料夾)

xcopy .\sharepoints\b01\*.txt xcopydir\b01\

xcopy .\sharepoints\*.txt .\dir\ /s

pushd \\sharedFolder

xcopy .\*.gif C:\Users\UserName\Desktop\gifCollect\ /s

popd

robocopy

Robocopy 快速複製、指定條件複製小工具

參數

用途

/mir

差異備份,並刪除目的端,源頭端不存在的檔案

/xf

*.txt 排除特定副檔名

/s

子複製,但不包括空資料夾

/e

包含空資料夾

pushd \\sharedFolder

REM 複製自 UNC 資料來源

robocopy .\ C:\Users\UserName\Desktop\div\ *.shtml /s

REM 複製寫入 UNC 資料來源

robocopy C:\Users\UserName\Desktop\div\ .\ *.shtml /s

popd

robocopy \\sharedFolder C:\Users\UserName\Desktop\div\ *.shtml /s

MSDN

檔名異動

資料夾內所有 txt 檔改為 md檔

rename *.txt *.md

移除所有檔案的副檔名

rename *.* *.

資料呈現

按照異動時間排列資料夾內檔案

dir /o:gd

ls -lh -ltr

參數

用途

/o:g

資料夾與檔案分順序排列

/o:d

按照時間排列

/o:-d

按照時間排列 - 最舊的的檔案優先

/o:s

按照時間排列 - 最大的檔案優先

最近60分鐘內異動過的檔案

find2 . -cmin -60

Append File

type *.txt > append.txt

顯示子檔案與時間 with 精美格式

for /r %F in (*) do @echo %~tF , %F

2018/08/15 上午 10:34 , C:\fileName1.docx

2018/08/15 上午 10:35 , C:\fileName2.docx

2018/08/15 上午 10:36 , C:\fileName3.docx

Copyright © 2088 俄罗斯世界杯主题曲_世界杯下一届 - pin8pin8.com All Rights Reserved.
友情链接