I want to delete document with name 'Test' in CSOM. this document is present in subfolder. whereas code should delete this document only if its parent folder(i.e subfolder) has more than 1 document. I know I can use CAML Query to get all documents with 'Test' name and then iterate it to check if its parent folder has more than 1 document and then delete this document. But I can not use this method as it will make more calls to SharePoint(5000 calls for 5000 listItems to get parentFolder files count). Please let me know if you guys have any other idea. SharePoint version is SharePoint 2013 onpremise.
Is there a way to create caml/LINQ query where I can check Folder (ItemChildCount>1 ) and (fileName Contains 'Test').
I have 60000+ document with name 'Test' in single site collection. I simply cannot use GetFolderByServerRelativeURL() to get folder object as it will degrade my server performance because it will hit server for 60000+ times. After analysis I found 'ItemChildCount' parameter which gives us count if files contained in folder. but my problem here is I can not apply 2 conditions at same time where these 2 conditions are dependent. I tried getting folder which has more than 1 File and now I want to apply filter to only these folder to return Files with FileName 'Test'
CAML Query I tried(I know it will not work, but thinking something similar):
<And> <Gt> <FieldRef Name='ItemChildCount'> <Value Type='Lookup'>1<value> <Gt> <Contains> <FieldRef Name='FileRef'> <Value Type='Text'>Test<value><Contains></And>