Box CLI - Recursively list all files within a folder older than a certain date

回答済み
新規投稿

コメント

4件のコメント

  • jcleblanc

    Hi  ,

     

    You can do something like this to list all files in a folder (0 in the example), sorted by date, and returning a content_modified_at field as well:

     

    box folders:items 0 --fields=content_modified_at --sort=date --json

     

     You can then parse this list for only the data older than the date you're looking for.

     

    - Jon

    0
    コメントアクション パーマリンク
  • BoxUser100

    But this only reports against the folder ID that I've listed and doesn't report on the folders within it. Does that mean I'd have to run this command against every subfolder as well?

    0
    コメントアクション パーマリンク
  • jcleblanc

    ,

     

    Unfortunately yes, you'll need to traverse the subfolders with the same call to get their data as well. There isn't a direct API method for obtaining data for the folder and all sub-folders. 

     

    As you mentioned your original post, search is a potential other option, but it really won't give you what you need because of the lack of a wildcard search. You have the ancestor_folder_ids parameter in search to explore within a series of folders, but unless there is a common search query that can be used to capture all results then you won't get everything.

     

    I'd recommend going with a recursive function that traverses the folder tree to get you all results. It's longer to set up and makes multiple API calls, but the data is far more accurate and doesn't incur the same 5-10 minute indexing delay that search has for newly uploaded files / folders.

     

    When creating this just be aware of the 16.67 API calls / sec / user rate limit and stagger your API calls to Box so that you don't receive a 429 rate limit error. 

     

    - Jon

     

     

    0
    コメントアクション パーマリンク
  • BoxUser100

    Thanks for the info. Very helpful.

     

    Btw, are there any Box CLI / API commands that will report back similar to what is offered in the console?

     

    What I mean is under [Admin Console > Reports > Folders and Files}

     

    2020-01-23 14_12_10-CAA _ Powered by Box.jpg

     

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。