How to search specific attachment type in Confluence
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
Purpose
This page contains a few way to search and list out all attachments in Confluence that has a specific extension or file type.
In this example, we are searching for all attachment with the extension .png
Solution
From the UI - Use Confluence's search syntax
Go to Search > AdvancedSearch
Choose Attachment in the Of Type section
Use the following search syntax to search the desired attachment type
/.*<attachment type>.*/ Example: /.*png.*/
From the Database:
Use the following SQL query:
select c.TITLE as Attachment_Name,
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.title like '%.png%';
The result will be as follows
From the Attachment folder:
Use the following unix search syntax:
find /<confluence_home>/attachments -type f | xargs file | grep PNG
Will only work on some specific platforms.