I am looking to write a CAML query that returns all folders recursively starting at a certain folder.

CAML Designer has helped me to get this far:

      <FieldRef Name='FileRef' />
            <FieldRef Name='ContentType' />
            <Value Type='Computed'>Folder</Value>
            <FieldRef Name='FSObjType' />
            <Value Type='Integer'>1</Value>
      <ViewAttributes Scope='RecursiveAll' />

This query starts at the root of the list. I want to start one level down in a particular folder. Can someone show me how to do that?

I thought to require that the name of the item contain /startingfolder/, but it seems that I can't but the / in the "contains" specification. How does one specify a string that contains a '/'?


2 Answers 2


You need either camlQuery.set_folderServerRelativeUrl(folderPath); (JSOM) or SPQuery.Folder (Server API). Both respect the "Recursive" attribute.

MSDN references:


If you want items in a specific folder you can use FileDirRef column and filter based on it..

    <FieldRef Name="FileDirRef" /> 
    <Value Type="Text">/folderPath</Value>
  • I don't want the items in a particular folder. I want everything below a specific folder.
    – Ira D
    Commented Aug 27, 2014 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.