Delete all attachments


Is there a way of deleting ALL attachments from a page?

I'm running 5.4.1, server

3 answers

This widget could not be displayed.

Hello Mick,

There is a feature request to add this functionality to Confluence here. I believe there are some workarounds in the comments there you could try. smile

This widget could not be displayed.

In addition to the information above: The Bob Swift's CLI add-on can help to remove a selection of attachments:

This widget could not be displayed.
Stephen Deutsch Community Champion Sep 25, 2015

Hi Mick,

If you load up the browser console (by pressing F12 or Ctrl/Cmd + Shift + i) and paste the following code in and press Enter, it will delete all attachments from the page you are currently viewing.

var deleteAttachments = function(attachments) {
    requestObject = [];
        contentType: 'application/json',
        type: 'POST',
        url: '/rpc/json-rpc/confluenceservice-v2/removeAttachment',
        data: JSON.stringify(requestObject),
        success: function( response ) {
            if (attachments.length) {
            } else {
var getAttachments = function(attachments, startIndex) {
    var attachments = attachments || [];
    var startIndex = startIndex || 0;
        url: contextPath + "/rest/prototype/1/content/" + AJS.params.pageId + "/attachments.json?start-index=" + startIndex,
        success: function(response) {
            attachments.push.apply(attachments, response.attachment);
            if ( attachments.length < response.size ) {
                startIndex += 50;
                getAttachments(attachments, startIndex);
            } else {

This should work for most versions of Confluence, including 5.4.1.  It will probably even work for Confluence Cloud.

Note: This doesn't check if you have permission to delete the attachments or not.  If not, it won't work.

Stephen, great, thanks for this. I haven't tried it yet, but will get back to you as soon as I have done. Cheers.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

161 views 16 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you