Skip to content

fileattrib

miscellaneous · scripts/miscellaneous/fileattrib.m

: [status, message, messageid] = fileattrib (file)
: […] = fileattrib (file, attrib)
: […] = fileattrib (file, attrib, userclass)
: […] = fileattrib (file, attrib, userclass, "s")

Query or change the attributes of files and folders.

With only file, the attributes of the file, folder or wildcard pattern are returned. Without file the current folder is used. On success message is a structure array, one element for each match, sorted by name, with the fields Name (absolute path), archive, system, hidden (these three are NaN outside Windows), directory, and the permission flags UserRead, UserWrite, UserExecute, GroupRead, GroupWrite, GroupExecute, OtherRead, OtherWrite and OtherExecute.

With attrib the attributes are changed. attrib is a string of words such as "+w", "-x" or "+r -w", which add or remove read, write and execute permission. userclass is a string of the letters u (user), g (group), o (others) or a (all, the default). The last argument "s" includes the contents of folders.

status is true on success. On failure it is false and message and messageid say why; without output arguments a failure is an error, and a successful query is printed.