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
.mdfiles 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.pyfile from this page. Click onexport.pyin 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 --versionin your terminal to check the installed version. If it returns 2.x, also trypython3 --version. If that works, replacepythonwithpython3in the script below. -
Run the script:
python export.py VAULT_ROOT ATTACHMENTS_FOLDER SOURCE_FOLDER [SOURCE_FOLDER ...] RESULT_ROOTArguments:
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.hereto dump it next to the script
python export.py ~/vault "Ξ© Backend/Attachments" folder1 folder2/subfolder ~/vault_exportThis will:
- Copy
folder1andfolder2/subfolderinto~/vault_export - Scan them for linked images
- Copy those images from
Ξ© Backend/Attachmentsinto~/vault_export/Ξ© Backend/Attachments
vault_export/
βββ folder1/
βββ folder2/
β βββ another/
βββ Ξ© Backend/
βββ Attachments/
βββ used1.png
βββ used2.jpg