Export one or more subfolders from an Obsidian vault – including all used images from your attachments folder – into a separate folder which mirrors the original Vault.
All done with a simple Python script, no external dependencies.
- Copies selected folders as-is
- Scans all contained
.md
files for image links like![[image.png|jpg|jpeg]]
- Copies only those images from your attachments folder
- Keeps result small and portable
- Python ≥ 3.6
- No external libraries required (only standard library)
-
Download the
export.py
file from this page. Click onexport.py
in file view above, then on the Download button in the top right above the code view. -
Ensure you have Python ≥ 3.6 installed. You can run
python --version
in your terminal to check the installed version. If it returns 2.x, also trypython3 --version
. If that works, replacepython
withpython3
in the script below. -
Run the script:
python export.py VAULT_ROOT ATTACHMENTS_FOLDER SOURCE_FOLDER [SOURCE_FOLDER ...] RESULT_ROOT
Arguments:
VAULT_ROOT
– absolute or relative path to your Obsidian vault root. Can use absolute and relative paths and paths may be quoted if they contain spaces etc.ATTACHMENTS_FOLDER
– relative path (from vault root) to your attachments folder, e.g."Ω Backend/Attachments"
SOURCE_FOLDER ...
– one or more folders (relative to vault root) you want to exportRESULT_ROOT
– path to the output folder, e.g.here
to dump it next to the script
python export.py ~/vault "Ω Backend/Attachments" folder1 folder2/subfolder ~/vault_export
This will:
- Copy
folder1
andfolder2/subfolder
into~/vault_export
- Scan them for linked images
- Copy those images from
Ω Backend/Attachments
into~/vault_export/Ω Backend/Attachments
vault_export/
├── folder1/
├── folder2/
│ └── another/
└── Ω Backend/
└── Attachments/
├── used1.png
└── used2.jpg