Dear Team,
I need to get list of files information of one folder by using folder name from site.
Could you please help on this!
Kind & Regards.
There are couple of ways to do it...
- Use search to find all the files/folders within a given folder by name path if you know it already. e.g. "/Site/Document Library/FolderA"
Search query, that will return list of nodes (including files/folders) that are directly within 'FolderA':
'PATH:"/app:company_home/st:sites/cm:testSite/cm:documentLibrary/cm:FolderA/*"'
Search query, that will return list of nodes (including files/folders) that are anywhere nested within 'FolderA':
'PATH:"/app:company_home/st:sites/cm:testSite/cm:documentLibrary/cm:FolderA//*"'
Search query, that will return list of nodes (only files) that are anywhere nested within 'FolderA':
'PATH:"/app:company_home/st:sites/cm:testSite/cm:documentLibrary/cm:FolderA//*" AND (TYPE:"cm:content")'
From resulted nodes, extract the required info as needed.
If you don't know exact path of the folder but know only name of the folder which can be anywhere in site document library then you can use combination of SearchService and FileFolderService. Using search service locate the nodeRef of the folder and using the nodeRef of the folder list all the files/folders within that folder using file folder service.
SearchService will execute following query to get the node of folder, e.g.:
'PATH:"/app:company_home/st:sites/cm:testSite/cm:documentLibrary//*" AND TYPE:"cm:folder" AND =@cm:\name:"FolderA"'
The above query will return node/nodes matching the exact name. Note you might get multiple nodeRefs if there are multiple folders with same name nested within parent folder (documentLibrary). If you know the exact path of the folder, you can easily use the above given queries that goes until the correct folder name by its path.
Once you have nodeRef of the folder, you can use FileFolderService e.g.:
List<FileInfo> listOfFiles = fileFolderService.listFiles(folderNodeRef); Iterate the list and extract the required info.
@akerikels46 wrote:
Dear Team,
I need to get list of files information of one folder by using folder name from site.
Could you please help on this!
Kind & Regards.
Looks like this question is exact copy of this thread: https://hub.alfresco.com/t5/alfresco-content-services-forum/fetching-files-list-from-folder/m-p/3033...
@akerikels46 have you checked the above thread ?
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.