The iCommands
allow to execute most metadata tasks also via command-line interface (CLI). This section will explain how to:
While the iCommands Wiki section contains the information to get you started using the iCommands
and also lists the commands that can be used for metadata management, the current section will further built on top of this by providing more detailed examples.
Notes:
imeta
command, you have to specify if you are working on a file (data object) or folder (collection). This can be achieved by specifying the additional -d
(for files) or -C
(for folders) flags when using the command (see below for examples).imeta
command, you can use single or double quotes around an entry if it includes blanks, for example imeta add -d <path> Author 'Name Surname
'.
The imeta
command is the relevant sub-command from the iCommands
packages that is used to work with metadata from the CLI.
You can execute the following command from the CLI to get an explanation of the imeta
command as well as an overview of its possible usage:
$ imeta help
Furthermore, you can execute imeta help <subcommand>
to get a more detailed help displayed for the respective subcommand of imeta
.
For example imeta help add
would display information about the imeta add
subcommand which can be used to add metadata from the CLI (see below for examples).
This section contains some further important and helpful tips for the working with metadata from the CLI.
When copying a folder/file that contains metadata, the metadata is not copied to the copy of the file/folder!
# Check metadata for the original $ imeta ls -d example_file_9 AVUs defined for dataObj /rug/home/rdms-testers@rug.nl/example_file_9: attribute: Author value: Tester_2 units: ---- attribute: Distance value: 150 units: km # Make a copy of the file. $ icp example_file_9 example_file_9_copy # Check metadata for the copy. $ imeta ls -d example_file_9_copy AVUs defined for dataObj /rug/home/rdms-testers@rug.nl/example_file_9_copy: None
Of course, as with other iCommands
, it is possible to include the imeta
sub-command in scripts etc. to execute more advanced/extended tasks.
The interactive imeta
mode can be also used to pipe information into it and then automatically execute the desired tasks.
For example, one could combine and iquest
query to first select files that fulfill the query condition and then use this information to set metadata on all those files with one terminal statement:
iquest 'set -d %s/%s <attribute> <value> <unit>' "select COLL_NAME, DATA_NAME where COLL_NAME like '<path>' and DATA_NAME like 'TEST%'" | imeta # This example will first query for all files in the collection '<path>' and its sub-collections that have a name of the type 'TEST%' (e.g. 'TEST_Sample', 'TEST_Reaction', etc.). $ iquest 'set -d %s/%s Author "Name Surnmane"' "select COLL_NAME, DATA_NAME where COLL_NAME like '/rug/home/rdms-testers@rug.nl%' and DATA_NAME like 'TEST%'" # It will then use this query result and use them for the 'set -d <path>/<filename> <attribute> <value> <unit>' statement. set -d /rug/home/rdms-testers@rug.nl/TEST123.png Author "Name Surnmane" set -d /rug/home/rdms-testers@rug.nl/another_folder/TEST_File Author "Name Surnmane" set -d /rug/home/rdms-testers@rug.nl/another_folder/example_folder_4/TESTERS.pptx Author "Name Surnmane" set -d /rug/home/rdms-testers@rug.nl/another_folder/example_folder_6/TESTing_stuff.txt Author "Name Surnmane" # This will then be piped into 'imeta'. As a result the AVUs specified in the 'set' statement will be added to all files that met the query condition. $ iquest 'set -d %s/%s Author "Name Surnmane"' "select COLL_NAME, DATA_NAME where COLL_NAME like '/rug/home/rdms-testers@rug.nl%' and DATA_NAME like 'TEST%'" | imeta imeta>imeta>imeta>imeta>imeta> # As a result, the metadata was added to all the files that were found in a single command $ imeta ls -d /rug/home/rdms-testers@rug.nl/TEST123.png AVUs defined for dataObj /rug/home/rdms-testers@rug.nl/TEST123.png: attribute: Author value: Name Surnmane units: $ imeta ls -d /rug/home/rdms-testers@rug.nl/another_folder/TEST_File AVUs defined for dataObj /rug/home/rdms-testers@rug.nl/another_folder/TEST_File: attribute: Author value: Name Surnmane units: $ imeta ls -d /rug/home/rdms-testers@rug.nl/another_folder/example_folder_4/TESTERS.pptx AVUs defined for dataObj /rug/home/rdms-testers@rug.nl/another_folder/example_folder_4/TESTERS.pptx: attribute: Author value: Name Surnmane units: $ imeta ls -d /rug/home/rdms-testers@rug.nl/another_folder/example_folder_6/TESTing_stuff.txt AVUs defined for dataObj /rug/home/rdms-testers@rug.nl/another_folder/example_folder_6/TESTing_stuff.txt: attribute: Author value: Name Surnmane units: