How do I list and count all pages with attachments in Confluence?

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Purpose

To get a list of all pages in Confluence with the number or attachments.

Solution

Run the below query into your Confluence Database:

PosgreSQL
select count(c.TITLE) as "Number of attachments", 
s.spacename,
c2.TITLE as Page_Title,
'http://<confluence_base_url>/pages/viewpageattachments.action?pageId='||c.PAGEID as Location
from CONTENT c
join CONTENT c2 ON c.PAGEID = c2.CONTENTID
join SPACES s on c2.SPACEID = s.SPACEID
where c.CONTENTTYPE = 'ATTACHMENT'
and c.prevver is null
and c.content_status='current' 
group by Page_Title, s.spacename, c.PAGEID
order by 1 desc;


Replace <confluence_base_url> with your Confluence Base URL. This was tested against PostgreSQL.

Last modified on Nov 27, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.