Fetching files list from folder

cancel
Showing results for 
Search instead for 
Did you mean: 
akerikels46
Member II

Fetching files list from folder

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.

2 Replies
abhinavmishra14
Advanced

Re: Fetching files list from folder

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.
~Abhinav
(ACSCE, AWS SAA, Azure Admin)
abhinavmishra14
Advanced

Re: Fetching files list from folder


@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 ?

~Abhinav
(ACSCE, AWS SAA, Azure Admin)