Each client project is in a space and when the project is over, we need to be able to have them download the attachments without going page by page. The Pages we can export to one PDF file but no solution for attachments.
I will just add that if you want the files to be separately as files you can do that and ensure they have descriptive names. (and not face a problem with PDF export with certain types of attachments due to embed) there is another way.
import os
import xml.etree.ElementTree as ET
# Path to the directory where the files are saved
directory_path = r"path\to\html\export\attachments\folder"
# Path to the XML file
xml_file_path = r"path\to\file.xml"
# Parse the XML file
tree = ET.parse(xml_file_path)
root = tree.getroot()
# Create a dictionary to store file IDs and real names
file_dict = {}
# Extract file IDs and real names from the XML
for attachment in root.iter('object'):
attachment_class = attachment.attrib.get("class")
if attachment_class == "Attachment":
file_id = attachment.find("./id[@name='id']").text
real_name = attachment.find("./property[@name='title']").text
file_dict[file_id] = real_name
# Rename files in place
for root_folder, _, files in os.walk(directory_path):
# Create a dictionary to track counts of each file name in a directory
name_count = {}
for filename in files:
file_id, file_extension = os.path.splitext(filename)
# Check if the file ID exists in the dictionary
if file_id in file_dict:
real_name = file_dict[file_id]
base_name, ext = os.path.splitext(real_name)
# Check if the file name already exists in the directory
if base_name in name_count:
name_count[base_name] += 1
new_base_name = f"{base_name}_{name_count[base_name]}"
else:
new_base_name = base_name
name_count.setdefault(base_name, 1)
new_name = f"{new_base_name}{ext}"
old_path = os.path.join(root_folder, filename)
new_path = os.path.join(root_folder, new_name)
# Rename the file
os.rename(old_path, new_path)
print(f"Renamed: {old_path} -> {new_path}")
Hello @Angie Affolter - it's still pretty manual, but better than exporting page by page. I see two options:
Option 1 (formats space and supported attachments as pages)
Option 2 (manual export of each attachment)
Please let me know if this resolves your issue, or if you have additional questions!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks! That's what I was doing. I was hoping for a more user-friendly answer.
My IT guys found this info - not end user but might be a good alternative:
https://community.atlassian.com/t5/Confluence-questions/Export-spaces-and-attachments/qaq-p/135920
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
PDF shows this on the version of Confluence I am using. 7.4.7. is there an option to get the attachments?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Victor Prasad ,
you can export as XML and you will get also the attachments in the export.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.