12-05-2020 03:38 AM
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.
12-05-2020 04:33 PM
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.
12-05-2020 04:39 PM
@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 ?
Explore our Alfresco products with the links below. Use labels to filter content by product module.