- primary vault: the main vault from where I upstream notes
- secondary vault: one of the vault in the dependencies which will receive the notes moved from the primary vault
When I move notes from a vault to another one using the move note command, any images in the notes had to be moved manually and then eventually removed from the first one if not referenced anymore (to clean up space).
Thats particularly unpleasant when there are a lot of notes to be moved, especially with images shared between notes (some of which need to be moved and some not).
So I built a script that does that automatically.
- Notes are moved from the primary vault to the secondary vault only
- Only images are
I want to move macosx.md
note to secondary-vault
primary-vault/
├── dependencies/
│ └── some-folders-in-between/
│ └── secondary-vault/
│ └── notes/
│ ├── assets/
│ │ └── images/
│ │ └── tux-wallpaper.jpg
│ ├── root.md
│ └── linux.md
└── notes/
├── assets/
│ └── images/
│ ├── bliss-wallpaper.jpg
│ ├── sierra-wallpaper.jpg
│ └── mac-vs-pc.jpg
├── root.md
├── windows.md
└── macosx.md
windows.md
bliss-wallpaper.jpg
mac-vs-pc.jpg
macosx.md
sierra-wallpaper.jpg
mac-vs-pc.jpg
linux.md
tux-wallpaper.jpg
primary-vault/
├── dependencies/
│ └── some-folders-in-between/
│ └── secondary-vault/
│ └── notes/
│ ├── assets/
│ │ └── images/
│ │ └── tux-wallpaper.jpg
│ ├── root.md
│ ├── linux.md
│ └── macosx.md
└── notes/
├── assets/
│ └── images/
│ ├── bliss-wallpaper.jpg
│ ├── sierra-wallpaper.jpg
│ └── mac-vs-pc.jpg
├── root.md
└── windows.md
primary-vault/
├── dependencies/
│ └── some-folders-in-between/
│ └── secondary-vault/
│ └── notes/
│ ├── assets/
│ │ └── images/
│ │ ├── tux-wallpaper.jpg
│ │ ├── sierra-wallpaper.jpg
│ │ └── mac-vs-pc.jpg
│ ├── root.md
│ ├── linux.md
│ └── macosx.md
└── notes/
├── assets/
│ └── images/
│ ├── bliss-wallpaper.jpg
│ └── mac-vs-pc.jpg
├── root.md
└── windows.md
sierra-wallpaper.jpg
is moved fromprimary vault
tosecondary vault
and then removed fromprimary vault
because not referenced anymore in any of its notesmac-vs-pc.jpg
is moved fromprimary vault
tosecondary vault
but it is not removed fromprimary vault
because is still needed for the notewindows.md
Ideally, this script would be an npm package to be installed in the primary-vault
project. For now I use a combination of npm link
and npm bin
to call the script from the primary-vault
without installing dependencies.
- Node.js and npm (I have 20.11.1/10.2.4 on Windows 11)
- Clone this repo
- Go to the
dendron-move-images
folder - Link the library
npm link
- Go to your dendron primary vault
- Link on the other side
npm link dendron-move-images
- Run command with standard settings (while still in dendron primary vault)
dmi
l
: logs the primary-vault and secondary-vault datay
: skip confirmsvn
: define the secondary vault name. Without this will take the first vault in dependencies as the secondary vault.
dmi -ly --secondary-vault=other-vault
Will be
{
"l": true,
"y": true,
"secondary-vault": "other-vault"
}
- Images relative path shoud be customizable
- It crashes if any folder in the path
assets/images
does not exist, it should create them instead - Refactor tests
- Tests with images in comment blocks and remote images from the web
- Not tested with the youtube preview image format
Example: [![Developers](http://img.youtube.com/vi/KMU0tzLwhbE/1.jpg)](http://www.youtube.com/watch?v=KMU0tzLwhbE)
- npm package