~~Title: SetAttr ~~
The **SetAttr** internal command can be used to:
* Modify the attributes of files or folders
* Compress (by setting the **C** attribute) or encrypt files (by setting the **E** attribute), and set the default compression/encryption status for folders
* Modify the last modified and creation timestamps of files or folders
* Modify file metadata, either through a [[:file_operations:editing_metadata|user-interface]] or [[..:..:metadata_keywords:keywords_for_setattr_meta|programmatically]]
* Assign your own description to files and folders, and edit the internal [[:file_operations:creating_archives:zip_files:zip_comment|comment]] for a Zip archive
* Modify attributes of files on remote FTP sites
**Command Arguments:**
$$ Argument
$$ Type
$$ Possible values
$$ Description
$$ (#)//(no argument)//
$$ -
$$ -
$$ Displays the **[[:file_operations:changing_attributes|Change Attributes & Times]]** dialog, which lets you modify the attributes and timestamps of selected files and folders.
``SetAttr``
$$ ATTR
$$ /K
$$ ////
$$ Sets the specified attributes for selected files and folders, and clears all others. The //// value must consist of one or more of the following letters:
|**R**|Read-only (files can not be deleted or overwritten)|
|**A**|Archive (file needs to be archived, used by backup tools)|
|**H**|Hidden (files can be marked as hidden to hide them from the display)|
|**S**|System (file is a system file - usually set in conjunction with **H**)|
|**N**|Normal (normal attributes, none of the other attributes set)|
|**I** |Non-content Indexed (contents will not be indexed by the system)|
|**C**|Compressed (on NTFS-formatted drives only)|
|**E**|Encrypted (on NTFS-formatted drives only)|
Note that modifying the **C** or **E** attributes may take longer than normal, as the file data has to be (un)compressed or (un)encrypted. Setting these attributes for folders sets the default compression/encryption state for new files created in those folders. A file can be compressed, or encrypted, but not both at once.
``SetAttr ATTR rca``
$$ CHMOD
$$ /K
$$ ////
$$ Sets the specified attributes for files on a remote FTP site. The //// is specified using [[http://en.wikipedia.org/wiki/File_system_permissions#Octal_notation|octal notation]].
``SetAttr CHMOD 666``
$$ CLEARATTR
$$ /K
$$ ////
$$ Clears the specified attributes for selected files and folders. The specified attributes will be turned off, but other attributes will be untouched. See the description of the **ATTR** argument for a list of attribute values.
``SetAttr CLEARATTR c``
$$ CREATED
$$ /K
$$ ////
$$ Sets the creation timestamp for selected files and folders. The value for this argument can be given as either a date only, a time only, or a date and time.
The accepted formats for the date string are **YYYYMMDD** or **YYYY-MM-DD**, and the time string must be in the format **HH:MM:SS**.
If you specify a time as well as a date the time must come after the date, separated by a space, and you must enclose the entire value in quotes (because of the embedded space). If only a time is provided, the file's current date will be preserved (and vice versa).
``SetAttr CREATED "1973-09-22 3:35"``
$$
$$
$$ **now**
$$ Sets the creation timestamp to the current date and time.
``SetAttr CREATED=now``
$$
$$
$$ **modified**
$$ Copies the last modified timestamp of the file.
``SetAttr CREATED=modified``
$$
$$
$$ **taken**
$$ For image files, copies the //Date Taken// timestamp. If the file doesn't have an EXIF tag the creation timestamp won't be changed.
``SetAttr CREATED=taken``
$$
$$
$$ **digitized**
$$ For image files, copies the //Date Digitized// timestamp. If the file doesn't have an EXIF tag the creation timestamp won't be changed.
``SetAttr CREATED=digitized``
$$
$$
$$ **parent**
$$ Copies the creation timestamp from the parent folder.
``SetAttr CREATED=parent``
$$
$$
$$ **doccreated**
$$ For document files, copies the //Document Created// timestamp. If the file doesn't have this timestamp in its metadata the creation timestamp won't be changed.
``SetAttr CREATED=doccreated``
$$
$$
$$ **docedited**
$$ For document files, copies the //Document Last Edited //timestamp. If the file doesn't have this timestamp in its metadata the creation timestamp won't be changed.
``SetAttr CREATED=docedited``
$$
$$
$$ **docsaved**
$$ For document files, copies the //Document Last Saved// timestamp. If the file doesn't have this timestamp in its metadata the creation timestamp won't be changed.
``SetAttr CREATED=docsaved``
$$ DEHYDRATE
$$ /S
$$ //(no value)//
$$ For cloud files on Windows 10 and above, this command "dehydrates" the file (removes local data and replaces it with a placeholder). This is equivalent to the "Free up space" context menu command that OneDrive adds.
``SetAttr DEHYDRATE``
$$ DESCRIPTION
$$ /O
$$ //(no value)//
$$ Displays the **[[:file_operations:file_descriptions|Set Description]]** dialog, which lets you assign your own description string to selected files and folders.
``SetAttr DESCRIPTION``
$$
$$
$$ ////
$$ Sets the description for selected files and folders to the specified string.
``SetAttr DESCRIPTION "Project Files for Keith"``
Note that an empty string will be treated the same as not passing a string at all, causing the **[[:file_operations:file_descriptions|Set Description]]** dialog to open. If you want an empty string to clear the description, use the **SETDESCRIPTION** argument instead.
$$ FILE
$$ /M
$$ //, ...//
$$ Specifies the name of the file or files to modify. If you don't provide this argument the command operates on all selected items in the source Lister. This is the default argument for the **SetAttr** command - you don't need to specify the **FILE** keyword.
If you only specify the filename instead of the full path of the file or files, Opus will look in the current source folder. You can also specify a [[..:..:wildcard_reference:pattern_matching_syntax|wildcard pattern]]. Remember that if the filename contains spaces you need to enclose it in quotes.
``SetAttr *.xls DESCRIPTION "Annual Results for 2011" SETATTR r``
$$ FILTER
$$ /K
$$ ////
$$ Applies the specified filter to the contents of selected folders. This must have previously been created from the **[[:preferences:preferences_categories:filtering_and_sorting:filters|Filters]]** page in Preferences. You can also directly specify a [[..:..:wildcard_reference:pattern_matching_syntax|simple wildcard pattern]]
``SetAttr FILTER "temp files" ATTR n``
$$ FILTERDEF
$$ /K/R
$$ ////
$$ Lets you define a filter in [[:file_operations:filtered_operations:textual_filters|text format]] to filter the contents of selected folders. This is similar to the **FILTER** argument, however the filter does not need to be predefined.
This is a **/R** argument and so everything after the **FILTERDEF** keyword will be treated as the argument's value.
``SetAttr ATTR n FILTERDEF name match *.zip and size match > 2 mb``
$$ META
$$ /O/M
$$ //(no value)//
$$ Displays the **[[:file_operations:editing_metadata|Set Metadata]]** dialog, which lets you modify the metadata for selected files and folders.
``SetAttr META``
$$
$$
$$ //keyword:, ...//
$$ Sets the specified metadata fields to the supplied values. Changes are made (where applicable) to all selected files.
Each //keyword:// pair must be enclosed in quotes if the value contains any spaces. This argument can accept multiple //keyword:// pairs to make changes to more than one metadata field at once.
See the section on [[:file_operations:editing_metadata:programmatic_setting_of_metadata|programmatic setting of metadata]] for more information.
``SetAttr META "artist:Pink Floyd" "album:Dark Side of the Moon"``
$$ MODIFIED
$$ /K
$$ ////
$$ Sets the last modified timestamp for selected files and folders. The value for this argument can be given as either a date only, a time only, or a date and time.
The accepted formats for the date string are **YYYYMMDD** or **YYYY-MM-DD**, and the time string must be in the format **HH:MM:SS**.
If you specify a time as well as a date the time must come after the date, separated by a space, and you must enclose the entire value in quotes (because of the embedded space). If only a time is provided, the file's current date will be preserved (and vice versa).
``SetAttr MODIFIED 20080110``
$$
$$
$$ **now**
$$ Sets the last modified timestamp to the current date and time.
``SetAttr MODIFIED=now``
$$
$$
$$ **created**
$$ Copies the creation timestamp of the file.
``SetAttr MODIFIED=created``
$$
$$
$$ **taken**
$$ For image files, copies the //Date Taken// timestamp. If the file doesn't have an EXIF tag the last modified timestamp won't be changed.
``SetAttr MODIFIED=taken``
$$
$$
$$ **digitized**
$$ For image files, copies the //Date Digitized// timestamp. If the file doesn't have an EXIF tag the last modified timestamp won't be changed.
``SetAttr MODIFIED=digitized``
$$
$$
$$ **parent**
$$ Copies the last modified timestamp from the parent folder.
``SetAttr MODIFIED=parent``
$$
$$
$$ **doccreated**
$$ For document files, copies the //Document Created// timestamp. If the file doesn't have this timestamp in its metadata the last modified timestamp won't be changed.
``SetAttr MODIFIED=doccreated``
$$
$$
$$ **docedited**
$$ For document files, copies the //Document Last Edited //timestamp. If the file doesn't have this timestamp in its metadata the last modified timestamp won't be changed.
``SetAttr MODIFIED=docedited``
$$
$$
$$ **docsaved**
$$ For document files, copies the //Document Last Saved// timestamp. If the file doesn't have this timestamp in its metadata the last modified timestamp won't be changed.
``SetAttr MODIFIED=docsaved``
$$ PIN
$$ /O
$$ //(no value)//
$$ For cloud files on Windows 10 and above, this command toggles the "pinned" status of the file on and off. This is equivalent to the "Always keep on this device" context menu command that OneDrive adds. When a file is "pinned", it's always kept on the device. When it's "unpinned" it may or may not be kept locally.
``SetAttr PIN``
$$
$$
$$ **yes**
$$ Sets the pinned state on selected cloud files.
``SetAttr PIN=yes``
$$
$$
$$ **no**
$$ Clears the pinned state on selected cloud files.
``SetAttr PIN=no``
$$ RECURSE
$$ /O
$$ //(no value)//
$$ Changes made by this command will be recursively applied to files within selected folders. This does not affect the **META** argument - only attributes, timestamps and descriptions can be applied recursively.
``SetAttr CLEARATTR hs RECURSE``
$$
$$
$$ **no**
$$ Prevents the command from working recursively if the recurse option has been turned on by default.
``SetAttr SETDESCRIPTION="2023 Trip To Japan" RECURSE=no``
$$ SETATTR
$$ /K
$$ ////
$$ Sets the specified attributes for selected files and folders. The specified attributes will be turned on, but other attributes will be untouched. See the description of the **ATTR** argument for a list of attribute values.
``SetAttr SETATTR r``
$$ SETDESCRIPTION
$$ /O
$$ //(no value)//
$$ Clears the description for selected files and folders.
``SetAttr SETDESCRIPTION``
The difference between the **DESCRIPTION** and **SETDESCRIPTION** arguments is what they do when not given a value. **SETDESCRIPTION** clears the description while **DESCRIPTION** opens a dialog for you to type in a description.
$$
$$
$$ ////
$$ Sets the description for selected files and folders to the specified string.
``SetAttr SETDESCRIPTION "Approved for release"``
$$ TOGGLEATTR
$$ /K
$$ ////
$$ Toggles (inverts) the state of the specified attributes. If each attribute specified is currently set it will be cleared, and vice versa. Attributes that aren't specified will be unaffected. See the description of the **ATTR** argument for a list of attribute values.
``SetAttr TOGGLEATTR h``
$$ ZIPCOMMENT
$$ /S
$$ //(no value)//
$$ Lets you edit the internal [[:file_operations:creating_archives:zip_files:zip_comment|Zip comment]] when viewing the contents of a Zip archive. The comment is stored inside the Zip file and can be displayed by other Zip tools.
``SetAttr ZIPCOMMENT``