How to list and set metadata using iMETA and WILDCARDS?

226 views
Skip to first unread message

mauro....@cmcc.it

unread,
May 12, 2022, 10:25:24 AM5/12/22
to iRODS-Chat
Dear Users,

using imeta irods command I'm able to list and set metadata for a single file.

Example:

imeta ls -d /idas/home/user/TEST3.iso

AVUs defined for dataObj /idas/home/user/TEST3.iso:
attribute: end_retention
value: 2022-05-20
units:
----
attribute: Filetype
value:  # ISO 9660 CD-ROM filesystem data 'CentOS 7 x86_64' (bootable)
units:
----
attribute: retention
value: 5
units: months
----
attribute: start_retention
value: 2022-04-20
units:

imeta set -d /idas/home/user/TEST3.iso retention 6 months

imeta ls -d /idas/home/user/TEST3.iso

AVUs defined for dataObj /idas/home/user/TEST3.iso:
attribute: end_retention
value: 2022-05-20
units:
----
attribute: Filetype
value:  # ISO 9660 CD-ROM filesystem data 'CentOS 7 x86_64' (bootable)
units:
----
attribute: retention
value: 6
units: months
----
attribute: start_retention
value: 2022-04-20
units:

Could you please help me to:

- list metadata for all files matching the name TEST* (all TEST* files are saved in the same directory)
- set metadata for all files matching the name TEST* (all TEST* files are saved in the same directory)

I didn't understand how to correctly use imeta wildcards.
Could you please show me an example?

Thank you in advance,
Mauro

tedgin...@gmail.com

unread,
May 12, 2022, 1:41:22 PM5/12/22
to iRODS-Chat
Hi Mauro.

You can't use wildcards with imeta to list or set metadata based on a data object name pattern, unfortunately. You can use iquest in combination with imeta to do these tasks.

The following statement should list all of the data objects named TEST* in the collection /path/to/coll along with their AVUs.

iquest "select DATA_NAME, META_DATA_ATTR_NAME, META_DATA_ATTR_VALUE, META_DATA_ATTR_UNITS where COLL_NAME = '/path/to/coll' and DATA_NAME like 'TEST%'"

The following statement should set the AVU <attribute, value, unit> on all of the data objects named TEST* in the collection /path/to/coll.

iquest 'set -d %s/%s attribute value unit' "select COLL_NAME, DATA_NAME where COLL_NAME = '/path/to/coll' and DATA_NAME like 'TEST%'" | imeta

Cheers,
Tony

mauro....@cmcc.it

unread,
May 13, 2022, 4:41:32 AM5/13/22
to iRODS-Chat
Hi Tony,

many thanks for your help.
I just tried your solution and it works :)

iquest 'set -d %s/%s retention 5 months' "select COLL_NAME, DATA_NAME where COLL_NAME = '/idas/home/user' and DATA_NAME like 'TEST%'" | imeta
imeta>imeta>imeta>

iquest "select DATA_NAME, META_DATA_ATTR_NAME, META_DATA_ATTR_VALUE, META_DATA_ATTR_UNITS where COLL_NAME = '/idas/home/user' and META_DATA_ATTR_NAME = 'retention' and DATA_NAME like 'TEST%'"
DATA_NAME = TEST3.iso
META_DATA_ATTR_NAME = retention
META_DATA_ATTR_VALUE = 5
META_DATA_ATTR_UNITS = months
------------------------------------------------------------
DATA_NAME = TEST4.iso
META_DATA_ATTR_NAME = retention
META_DATA_ATTR_VALUE = 5
META_DATA_ATTR_UNITS = months
------------------------------------------------------------

I will try to apply the same procedure against a big number of files ( I need to fix the retention value for a lot of files ).
Do you think that the command output "imeta>imeta>imeta>" is normal and that I can ignore it?

Thank you,
Mauro

tedgin...@gmail.com

unread,
May 13, 2022, 12:33:33 PM5/13/22
to iRODS-Chat
You can ignore the "imeta>imeta>...". It's normal, or at least it is when I use imeta that way.

mauro....@cmcc.it

unread,
May 14, 2022, 12:24:24 PM5/14/22
to iRODS-Chat
Thank you very much, Tony :)

Mauro Tridici

unread,
May 16, 2022, 10:14:01 AM5/16/22
to irod...@googlegroups.com
Hello Tony,

I’m still here to ask you my last question:

I just noticed that I should fix the “retention” field value for every file saved in /idas/home/user folder (user’s home directory) and in each /idas/home/user subfolder (that is, /idas/home/user/* in recursive mode).
How I should modify these two commands in order to complete this task? I would like to avoid to manually repeat the same command for each subfolder (there are a lot fo subfolders…)

iquest 'set -d %s/%s retention 5 months' "select COLL_NAME, DATA_NAME where COLL_NAME = '/idas/home/user' and DATA_NAME like 'TEST%'" | imeta
iquest "select DATA_NAME, META_DATA_ATTR_NAME, META_DATA_ATTR_VALUE, META_DATA_ATTR_UNITS where COLL_NAME = '/idas/home/user' and META_DATA_ATTR_NAME = 'retention' and DATA_NAME like 'TEST%'"

Thank you in advance,
Mauro

--
--
The Integrated Rule-Oriented Data System (iRODS) - https://irods.org
 
iROD-Chat: http://groups.google.com/group/iROD-Chat
---
You received this message because you are subscribed to the Google Groups "iRODS-Chat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to irod-chat+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/irod-chat/73107d0f-d5fd-43ca-9557-747ee8d58d33n%40googlegroups.com.

Tony Edgin

unread,
May 16, 2022, 12:12:53 PM5/16/22
to irod...@googlegroups.com
Hi Mauro.

You  just need to select COLL_NAME with `like` expression and a wildcard appended to the base folder path to get the subfolders. The `||` operator means "or" in the updated queries. Since you may get a lot of results, I added the `--no-page` option. For the second query, I added COLL_NAME to the result set, since its value will no longer be a constant.

iquest --no-page 'set -d %s/%s retention 5 months' "select COLL_NAME, DATA_NAME where COLL_NAME = '/idas/home/user' || like '/idas/home/user/%' and DATA_NAME like 'TEST%'" | imeta

iquest --no-page "select COLL_NAME, DATA_NAME, META_DATA_ATTR_NAME, META_DATA_ATTR_VALUE, META_DATA_ATTR_UNITS where COLL_NAME = '/idas/home/user' || like '/idas/home/user/%' and META_DATA_ATTR_NAME = 'retention' and DATA_NAME like 'TEST%'"

Cheers,
Tony

Reply all
Reply to author
Forward
0 new messages