file_operations:editing_metadata:programmatic_setting_of_metadata

Using the SetAttr META command it is possible to automate changes to file metadata.

For example, you could set up a menu to apply different ratings to files.

This menu was created from six different commands, each of which applies a different rating to selected files.

  • The command for Clear rating is SetAttr META rating:0
  • The command for 1 star is SetAttr META rating:1
  • The command for 2 stars is SetAttr META rating:2 (and so on.)

The general template for this command is:

SetAttr META keyword:<value> keyword:<value> ...

You can specify as many keyword:<value> pairs on the command line as you like. The keyword must be one of the metadata keywords listed on the Keywords for SetAttr META page. <value> will vary depending on the field you are setting.

If the <value> part is missing, the specified keyword will be cleared. For example,

SetAttr META album

It is important to remember that if <value> contains any embedded spaces, the entire keyword:<value> pair must be enclosed with quotes. For example,

SetAttr META "album:Dark Side Of The Moon" "albumartist:Pink Floyd"

The specified keyword can also contain wildcards, to apply the same value to multiple metadata fields at once. You could, for instance, set the artist, albumartist and origartist fields all at once with *artist. You can also use this to clear all metadata fields:

SetAttr META

Some metadata values support more complex data than a simple string. For example, you can apply an offset to the EXIF date taken field, to adjust the current value rather than replacing it completely. To subtract one hour, the command would be:

SetAttr META datetaken:-1

See the Keywords for SetAttr META page for a full list of keywords and they values they can accept.

You can also copy certain combinations of metadata from a source file to the target files, using the copyfrom keyword. The template for this is:

SetAttr META copyfrom:<type>,<filename>

 In the above, <type> is a numeric value that represents which type of properties should be copied. The available values for <type> are:

TypeCategoryCopies
1MusicArtist, Album, Year, Genre
2MusicAll except Title and Track
3MusicAll
4DocumentsAuthor and Ownership
5DocumentsAll except Title and Subject
6DocumentsAll
7MovieDirector, Producer, Writer
8MovieAll except Title
9MovieAll
10PictureAuthor and Ownership
11PictureGPS
12PictureGPS and Camera
13PictureAuthor, Ownership, Camera
14PictureAuthor, Ownership, GPS
15PictureAll

<file> is the source file to copy the specified metadata from. Remember that if the filename contains spaces, the keyword:<value> pair must be enclosed with quotes. For example,

SetATTR META "copyfrom:8,/myvideos/my home movie1.avi"