
Adds a page under Tools that exports your whole document library as one .zip file,
sorted into a folder per Document Category, alongside a CSV manifest describing
every document.
Requires Document Library Lite (free) or Document Library Pro by Barn2 Plugins:
https://barn2.com/wordpress-plugins/document-library-pro/
This utility is provided with the approval of, but is not affiliated with, Barn2 Plugins.
Tools > Export Documents. Requires the export capability, which belongs to
Administrators by default.
Options:
Click Build archive, then Download .zip.
The archive:
Some-Category/
Another-Category/
_no-category/
document-library-manifest.csv
Folder names come from the category name, alphabetically ordered, so repeat exports
match. The download is named document-library-YYYY-MM-DD.zip.
The manifest has a row per document: ID, title, status, slug, permalink, dates,
author, link type, path in the zip, filename, size, attachment ID, external URL,
taxonomy terms, document metadata, and a Notes column flagging anything unusual.
Documents that point at a file hosted elsewhere have nothing on the server to
archive. They appear in the manifest with their URL and are counted as skipped.
Missing files are reported the same way.
Progress runs in batches, so a large library will not time out. Leaving the page
mid-build abandons the archive, which is cleaned up within six hours. The archive is a
download: it is deleted from the server once sent, and nothing is added to the Media
Library. It can contain private and draft documents, so treat it accordingly.
// Smaller batches on a host with a short execution limit.
add_filter( 'circulationdesk_export_tool_batch_size', function () { return 10; } );
// Build the archive somewhere specific.
add_filter( 'circulationdesk_export_tool_staging_dir', function () { return '/var/tmp/dl-exports'; } );
// Change the download filename.
add_filter( 'circulationdesk_export_tool_download_filename', function () { return 'documents.zip'; } );
// Add extra postmeta keys as manifest columns.
add_filter( 'circulationdesk_export_tool_manifest_meta_keys', function ( $keys ) { return $keys; } );