Below PowerShell script gets files from the given folder recursively:
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Function IterateFolderRecurresive([Microsoft.SharePoint.Client.Folder] $fld, [Microsoft.SharePoint.Client.ClientContext] $ctx)
{
Write-Host "Files from " $fld.Name
$files = $fld.Files
$ctx.Load($fld.Files)
$ctx.Load($fld.Folders)
$ctx.ExecuteQuery()
foreach($file in $files)
{
Write-Host $file.Name
}
foreach($subFolder in $fld.Folders)
{
IterateFolderRecurresive $subFolder $ctx
}
}
$webUrl = Read-Host "Enter your web Url"
#Start Url from relative to Document Library
$folderRelativeUrl ="Documents/Folder2.0/"
$password = Read-Host -Prompt "Enter password" -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$credentials = New-Object System.Net.NetworkCredential("[UserName]", $password)
$ctx.Credentials = $credentials
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()
$folder = $web.GetFolderByServerRelativeUrl($web.ServerRelativeUrl + $folderRelativeUrl)
$ctx.Load($folder)
$ctx.ExecuteQuery()
IterateFolderRecurresive $folder $ctx
Hope it will help to you..
http://site/_api/web/getfolderbyserverrelativeurl('folder url') /files
. – Akhoy Aug 1 '15 at 10:01