Box CLI Search based only on metadata
That's my first post on this forum, but I could find the answer by myself, so maybe someone can help me out.
I use scripts based on Box CLI to automate a number of things. One of the thing I need to do is to detect files within a folder more recent that a certain date to trigger some action on them. Therefore, I would like to "search" files (or folders) based on their last update date. The good news is that the search feature within Box CLI has an option "--updated-at-from" and "--updated-at-to". The bad news is that the search feature requires an argument which is a QUERY. If I understand well, the QUERY is a string that is searched within the file or in the name etc. But that is not what I want to do, my intention is to search for ALL files based on their update date.
Unfortunately, it is not possible to search for ALL files based on their update date; a search query must be provided, per the API documentation. One way to get all files in a specific folder updated after a certain date would be to list al the files in that folder and filter to just the ones with a modified_at value greater than the date. You could use the jq tool (or something similar) to manipulate the JSON the CLI returns to accomplish this, doing something like this:
box folders:items 0 --fields name,modified_at --json | jq '. | select(.modified_at >= "2019-01-01T00:00:00-08:00")'
Please sign in to leave a comment.