FileSetAttrib

首页  后退  前进

FileSetAttrib
down2

FileSetAttrib

设置一或多个文件或目录的属性.

 

FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse = 0] )

参数

file pattern

目标文件, 例如: C:\*.au3, C:\Dir. (接受通配符 * 和 ? - 见备注)

+-RASHNOT

设置或清除的属性, 例如: "+A", "+RA-SH"

recurse

[可选]

   $FT_NONRECURSIVE (0) - 不递归 (默认)

   $FT_RECURSIVE (1) - 目录递归进入.

 

常量定义在 FileConstants.au3

返回值

成功:

返回 1.

失败:

返回 0, 发生错误.

备注

有关通配符的论述参考 FileFindFirstFile().

 

参数"文件"不可以含有空格!

使用 + 或 - 修改属性:

"R" = 只读文件

"A" = 存档文件

"S" = 系统文件

"H" = 隐藏文件

"N" = 普通文件

"O" = 脱机文件

"T" = 临时文件

 

(注意, 本函数不能设置压缩/目录属性.)

 

函数示例

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
If MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "", "Note: This is an example and shouldn't be run under normal circumstances. " & @CRLF & @CRLF & "Do you wish to run the example?") = $IDYES Then
    ; Mark all .au3 files in current directory as read-only and system.
    If Not FileSetAttrib(@ScriptDir & "\*.au3", "+RS") Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Problem setting attributes.")
    EndIf
    ; Mark all .bmp files in @HomeDrive and sub-directories writable and archived.
    If Not FileSetAttrib(@HomeDrive & "\*.bmp", "-R+A", $FT_RECURSIVE) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Problem setting attributes.")
    EndIf
EndIf

----------------------------------------

 

该函数可以通过命令 exect 调用

参见:

FileGetAttrib, FileSetTime

例子
copy

exect=FileSetAttrib('C:\Test\*.txt','+RS') ;; 将Test文件夹中的所有txt文件设置为只读属性和"System"

 

exect=FileSetAttrib('C:\Test\test.txt','-RS') ;; 从文件test.txt中删除属性"只读"和"系统"

up2

tcimage © Аверин Андрей для Total Commander Image Averin-And@yandex.ru