Welcome to the new Box Support website. Check out all the details here on what’s changed.

BoxSDK (Python) - Search for files of certain extension

New post

Comments

2 comments

  • jcleblanc

    Hi ,

     

    With the way the search endpoint works, you won't be able to set wildcard search params (or a null value) within the query itself. This article gives some good insights into how it functions, specifically under the "Wildcard searches" section.

     

    So, there are a few options that might work. If you want to search for common file names / file name parts (where there is a common naming convention), you can do something like: 

     

    search_term = 't'
    type = 'file'
    
    content = client.search().query(search_term, result_type=type, file_extensions=['pdf', 'txt'])

     

    The other option would be to use the Get Folder Items endpoint. This will return all items within a given folder, which you can then loop through and filter for any without a matching extension.

     

    I know it's not an ideal scenario, but hopefully one of those should get you what you need.

     

    Thanks,

    Jon

    0
    Comment actions Permalink
  • dblx

    Apologies if this is the wrong thread for this question, but it was the closest one I could find for the issue of searching for a particular file extension. My university recently migrated everything to Box, so I can't use the Windows file explorer search. I need to search all my folders for my matlab function and script files (*.m). How do I do that in Box drive? Searching "*.m" appears to literally return everything with an "m" in it, which is pretty much everything among my thousands and thousands of files.

    0
    Comment actions Permalink

Please sign in to leave a comment.