Skip to content

vrtmrz/obsidian-screwdriver

Repository files navigation

Screwdriver

Screwdriver exports files from inside your vault into a Markdown note, and restores those files from that note later.

screenshot

It is useful for moving or synchronising files that normal Markdown synchronisation workflows may not handle well, such as plug-in files, theme files, CSS snippets, or hidden files under .obsidian.

Since v0.0.7, Screwdriver can be controlled from note properties.

screenshot2

Features

  • Export files from selected folders into the current note.
  • Fetch remote files into the current note.
  • Restore exported files back into your vault.
  • Filter or ignore files while exporting.
  • Restore files under hidden folders such as .obsidian.

Important

Screwdriver stores exported files inside a Markdown note. The note can become very large. Consider excluding Screwdriver notes from plug-ins that scan Markdown content heavily, such as Templater or Dataview.

How to use

Install

You can install Screwdriver in either of these ways:

  • From Community Plugins
  • Via BRAT

Basic local export workflow

Use these commands from the command palette:

  1. Screwdriver: Create local export note
  2. Screwdriver: Add folder to this export note
  3. Screwdriver: Export files into this note
  4. On another device or vault, run Screwdriver: Restore files from this note

The first command creates the required properties on the active note. The second command adds a folder to the targets property. The third command reads those properties and embeds the matching files into the note body.

Screwdriver note properties

A Screwdriver note for local exports uses properties like this:

targets:
  - .obsidian/plugins/tagfolder
urls: []
ignores:
  - /node_modules
  - /.git
filters:
  - main\.js$
  - manifest\.json$
  - styles\.css$
comment: "Use 'Add folder to this export note' to add targets"
tags: []
adjustObsidianDir: true
skipNewFile: false
skipOldFile: false

You usually do not need to write this by hand. Run Screwdriver: Create local export note on an empty note, then run Screwdriver: Add folder to this export note.

When you choose a plug-in or theme folder, Screwdriver adds common filters automatically:

  • Plug-ins: main.js, manifest.json, styles.css
  • Themes: manifest.json, theme.css
  • CSS snippets: selected .css files

You can edit these properties manually if needed:

  • targets: folders to export from
  • urls: remote files to fetch
  • ignores: paths to skip while exporting
  • filters: regular expressions for files to include
  • adjustObsidianDir: store the Obsidian config folder as .obsidian so the note can be restored across vaults
  • skipNewFile: do not overwrite an existing file with a newer exported copy
  • skipOldFile: do not overwrite an existing file with an older exported copy

To export several folders into the same note, run Screwdriver: Add folder to this export note more than once.

Fetch remote files

To create a note for remote files, run:

Screwdriver: Create remote fetch note

Then add URLs to the urls property and run:

Screwdriver: Export files into this note

This is useful for storing CSS snippets or other small text assets from remote sources.

Export files

Run:

Screwdriver: Export files into this note

Screwdriver keeps the note properties and appends exported files to the note body.

Example output:

---
targets:
  - .obsidian/plugins/tagfolder
urls: []
ignores:
  - /node_modules
  - /.git
filters:
  - main\.js$
  - manifest\.json$
  - styles\.css$
comment: "Use 'Add folder to this export note' to add targets"
tags: []
adjustObsidianDir: true
skipNewFile: false
skipOldFile: false
---

# .obsidian/plugins/tagfolder/main.js
- Created :2023/7/12 9:28:27
- Modified:2023/8/25 17:52:29

```screwdriver:.obsidian/plugins/tagfolder/main.js:plain:1692953549000
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plug-in
*/
```

Tip

You can edit exported text files directly in the note before restoring them.

Restore files

Run:

Screwdriver: Restore files from this note

Screwdriver restores files from fenced code blocks whose opening line starts with ```screwdriver:. It also supports compatible fenced blocks that contain a filename after the opening backticks.

Important

Restore only from notes you trust. Screwdriver writes files to paths recorded in the note.

Restore paths must be canonical, portable Vault-relative paths using / separators. Screwdriver skips absolute paths, parent traversal, backslashes, empty path components, control characters, and names that are invalid or reserved on common desktop platforms. When adjustObsidianDir is enabled, the portable .obsidian/ prefix is validated and mapped below the active Vault configuration directory.

Screwdriver can be useful with Self-hosted LiveSync or remotely-save when you want to sync configuration files between devices.

About

No description, website, or topics provided.

Resources

License

Stars

22 stars

Watchers

2 watching

Forks

Sponsor this project

 

Packages

 
 
 

Contributors