Deleting more than one attachment at a time?
Asked by Jerry D.:

Is there a faster way to delete topic attachments? In our 5.0 version, you can only delete one attachment at a time !@#$%\^\&


Answers:
author: Stephen Deutsch
body: There's some custom HTML you can add that will allow you to delete up to 20 attachments at a time. The code is in this JIRA ticket's comments, but I will also copy it to this page:

<https://jira.atlassian.com/browse/CONF-17020>

```
&lt;script&gt;AJS.toInit(function() {  if ( AJS.Meta.get('is-space-admin') || jQuery('#space-admin-link').length &gt; 0 ) {    if ( window.location.href.indexOf("viewpageattachments.action") &gt;= 0 &amp;&amp; jQuery(".removeAttachmentLink").length &gt; 1 ) {      jQuery('tr[id^="attachment-"]').each(function() {        var attachmentId = jQuery(this).attr("id").substring(11);        jQuery(this).find(".removeAttachmentLink").parent().after('&lt;li&gt;&lt;input type="checkbox" class="bulk-attachment-delete" name="' + this.getAttribute("data-attachment-filename") + '" value="' + attachmentId + '"&gt;&lt;/li&gt;');      });      jQuery('table.attachments th.actions-column').css('text-align','right').css('width','220px');      jQuery('th.actions-column').html('&lt;input type="checkbox" onclick="if (this.checked) { jQuery(\'.bulk-attachment-delete\').attr(\'checked\',\'checked\') } else { jQuery(\'.bulk-attachment-delete\').removeAttr(\'checked\') }"&gt;&amp;nbsp;');      jQuery('#download-all-link').css('display','inline-block').after('&lt;a href="#" title="Delete all selected attachments" style="display:inline-block;float:right;padding-right:20px;margin-top:10px;padding-left:20px;background:url(\'data:image/gif;base64,R0lGODlhEAAQAKIAAHBwcOTk5Hh4eP///4GBgZOTkwAAAAAAACH5BAAHAP8ALAAAAAAQABAAAAMpOLrcPiAC8RhV1wnJY8Yd91UkFEbPiToqkKrvGYdz9xAn8QRFVwQlUgIAOw==\') no-repeat left center;" onclick="removeAttachments(jQuery(\'.bulk-attachment-delete:checkbox:checked\'));return false;"&gt;Delete Selected Attachments&lt;/a&gt;');    }  }});var removeAttachments = function(checkboxes) {  var confluenceVersion = parseFloat(AJS.params.versionNumber.substring(0,3));  var doRemoveAttachments = function(checkboxes) {    if (checkboxes.length) {      var currentCheckbox = checkboxes.pop();      if ( confluenceVersion &gt;= 5.5 ) {        jQuery.ajax({          type: 'DELETE',          url: contextPath + '/rest/api/content/' + currentCheckbox.value,          success: function(response) {            doRemoveAttachments(checkboxes);          }        });      } else {        jQuery.ajax({dataType: 'json',          contentType: 'application/json',          type: 'POST',          url: contextPath + '/rpc/json-rpc/confluenceservice-v2/removeAttachment',          data: '[' + AJS.params.pageId + ',"' + currentCheckbox.name + '"]',          success: function( response ) {            if (response == true) {              doRemoveAttachments(checkboxes);            }          }        });      }    } else {      location.reload();    }  }  var dialog = new AJS.Dialog({    width: 400,    height: 170,    id: "areyousure-dialog",    closeOnOutsideClick: true  });  dialog.addHeader("Are you sure?");  dialog.addPanel("Panel 1", "&lt;p&gt;You are about to delete " + checkboxes.length + " attachments. Continue?&lt;/p&gt;", "panel-body");  dialog.addButton("OK", function (dialog) {    dialog.hide();    if (checkboxes.length &gt; 0) {      doRemoveAttachments(jQuery.makeArray(checkboxes));    }  });  dialog.addLink("Cancel", function (dialog) {    dialog.hide();  });  dialog.show();}&lt;/script&gt;
```


author: EPS Software Engineering AG
body: Hi Jerry,

Thank's for the idea. We will add this feature to our [Page Tree Eraser](https://marketplace.atlassian.com/plugins/eps.focuspro.PageTreeEraser/server/overview). In the mean time you could use our [Page Tree Creator](https://marketplace.atlassian.com/plugins/eps.focuspro.PageTreeCreator/server/overview) to copy the page tree without attachments, delete the original and move the copied back. Yes, for the moment it's a ugly work around.

Regards,  
Stephan


author: Bill Bailey
body: Not that I know of. It is frustrating. If I have to delete a lot of attachments, I copy out the content on the page temporarily, and then delete the page, followed by creating a new page with the same content, reattaching the attachments I want. Not a great solution, but sometimes faster.