批次處理Attrib命令

2019-10-16 23:00:12

批次處理Attrib命令用於顯示或設定當前目錄中的檔案的屬性

語法

attrib

範例
以下範例顯示attrib命令的不同變體(用法)。

@echo off
Rem Displays the attribites of the file in the current directory
Attrib
Rem Displays the attributes of the file lists.txt
attrib C:\tp\lists.txt
Rem Adds the "Read-only" attribute to the file.
attrib +r C:\tp\lists.txt
Attrib C:\tp\lists.txt
Rem Removes the "Archived" attribute from the file
attrib -a C:\tp\lists.txt
Attrib C:\tp\lists.txt

執行上面範例程式碼,輸出結果如下 -

A           C:\tp\assoclst.txt
A           C:\tp\List.cmd
A           C:\tp\lists.txt
A           C:\tp\listsA.txt
A           C:\tp\lists.txt
A    R      C:\tp\lists.txt
     R      C:\tp\lists.txt