modifyfileattributes
PATH
,
ATTRIBUTE
,
VALUE

The modifyfileattributes statement modifies one or more attributes of a file (or folder).


Parameters

This statement has three parameters:

path – is a path to the file or folder to be modified, including the file name (see Files and Folders for more information about file paths).

attribute – the attribute to be modified (see below). You can use multiple attribute/value pairs, or you can combine all of the attribute/value pairs into a dictionary and pass that into this parameter (in that case omit the value parameter).

value – the value of the option to be modified.


Description

This statement modifies one or more attributes of a file (or folder). For example you can change the creation or modification date, the permissions, etc. You can modify one attribute or several. For example, this code will change the creation and modification date of the Flower.jpg file to today at midnight.

modifyfileattributes "~/Pictures/Flower.jpg",
    "CREATED",superdate(today(),0),"MODIFIED",superdate(today(),0)

An alternate method is to combine all of the options into a single dictionary, like this:

modifyfileattributes "~/Pictures/Flower.jpg",
    initializedictionary(
        "CREATED",superdate(today(),0),
        "MODIFIED",superdate(today(),0)
    )

A possible advantage of using a dictionary is that you can package up all the options in advance in a variable.

File Attributes

The primary attributes that can be modified are:

There are three additional attributes that quite frankly, we don’t understand. However, these are attributes supported by macOS, so they are included.


See Also


History

VersionStatusNotes
10.2NewNew in this version.