No description
Find a file
Benjamin Filip Šikač bde43b95a7
Update README.md
2025-04-28 10:24:42 +02:00
IO feat: added export/import for obsidian settings 2025-04-28 08:58:59 +02:00
Models feat: added exclusion rules for folders and files with regex support 2025-04-13 20:22:20 +02:00
Settings feat: added export/import for obsidian settings 2025-04-28 08:58:59 +02:00
Utils removed * from obsidian import in favour of atomic imports 2025-04-28 08:58:12 +02:00
.editorconfig Initial commit 2024-09-17 10:23:12 +02:00
.eslintignore Initial commit 2024-09-17 10:23:12 +02:00
.eslintrc Initial commit 2024-09-17 10:23:12 +02:00
.gitignore Added new gitignore 2025-04-10 20:14:30 +02:00
.npmrc Initial commit 2024-09-17 10:23:12 +02:00
biome.json Formatting 2025-04-13 11:12:30 +02:00
bun.lockb added settings tab 2024-10-01 10:31:49 +02:00
esbuild.config.mjs Initial commit 2024-09-17 10:23:12 +02:00
LICENSE Create LICENSE 2025-03-08 09:23:14 +01:00
main.ts feat: added export/import for obsidian settings 2025-04-28 08:58:59 +02:00
manifest.json bumping version 2025-04-28 10:23:19 +02:00
package-lock.json added settings tab 2024-10-01 10:31:49 +02:00
package.json updated UI and started work on regexRules that will move items around 2024-10-09 11:10:43 +02:00
README.md Update README.md 2025-04-28 10:24:42 +02:00
styles.css feat: added auto time based moving, ribbon and cmd access to manual 2025-04-17 18:16:09 +02:00
tsconfig.json Initial commit 2024-09-17 10:23:12 +02:00
version-bump.mjs Initial commit 2024-09-17 10:23:12 +02:00
versions.json Initial commit 2024-09-17 10:23:12 +02:00

AutoMover plugin

This plugin is used for designating folders in which your files will be moved automatically. It seeks to be an alternative to the "https://github.com/farux/obsidian-auto-note-mover" plugin from farux. The problem I had with that plugin was the lack of support for regex and regex groups in the destination paths.

Therefore, this plugin supports regex and regex groups to create the destination paths unless they already exist.

How to use

Using the plugin doens't require any special setup. Just install it and you're good to go. Also, you can use it without knowing what regex is, but it's recommended to learn it to get the most out of this plugin.

Introduction to the UI

This image shows the UI of the plugin with numbers attached to each part of the UI. The numbers are elaborate below the image.

settingsUpdatedWithExportImport

  1. Plugin location: This is where you can access the plugin's settings.
  2. Export/Import: This is where you can export and import the settings you have set up.
  3. On-open toggle button: This button toggles whether the plugin will run when you open a file.
  4. Manual run button: This button will run the mover manually for all the files in the obsidian vault.
  5. Automatic moving toggle and input: This toggle and input will allow you to set a time interval in which the plugin will run automatically. If the time is not set it won't run automatically.
  6. Quick Tutorial: This is a quick tutorial and reminder on how to use the plugin.
  7. Search criteria: This is where you can input strings or regex that will be used to match the files you want to move.
  8. Destination path: This is where you can input the destination path for the files that match the search criteria.
  9. Add rule button: This button will add a rule to the list of rules.
  10. Delete rule button: This button will delete the selected rule from the list of rules.
  11. Duplicate rule button: This button will duplicate the selected rule from the list of rules.

Export and Import

The export and import buttons are used to export and import the settings you have set up. In case your device can't open a file manager for you to choose the destination and name for the file, then it will save the settings in the root folder of your vault with the name "AutoMoverSettings.json".

The same goes for the import button, if your device can't open a file manager for you to choose the file to import, then it will look for the file "AutoMoverSettings.json" in the root folder of your vault.

Importing new settings will overwrite the current settings you have set up and there is no undo button. Therefore, the best thing to do is to export the settings before importing new ones, in case you care about them.

Timer and timed moving

The time displayed is an interval, 20:00:00 will execucte every 20 hours. Other examples could include:

  1. 00:05:00 -> triggers every five minutes
  2. 00:00:05 -> triggers every five seconds
  3. 72:30:00 -> triggers every 3 days and 30 minutes (if your Device is online and obsidian runnning for that long)

Exclusion rules UI

From patch 1.0.2 onwards, you can exclude files and folders from being moved. The UI that is used for the exclusion rules is the same as the one used for the search criteria. But here is a quick glance at how it looks:

ImageOfExclusionRules

  1. Excluded folder or files: This is where you can input the folder or file paths you want to exclude from being moved.
  2. Add rule button: This button will add a rule to the list of rules.
  3. Delete rule button: This button will delete the selected rule from the list of rules.
  4. Duplicate rule button: This button will duplicate the selected rule from the list of rules.

Command palette

From patch 1.0.4 onwards, you can access the plugin from the command palette. With the available commands being:

  • AutoMover: Move files: This command will run the mover manually for all the files in the obsidian vault.

Sidebar (Ribbon)

From patch 1.0.4 onwards, you can access the plugin from the sidebar (ribbon). In case you need something faster than the command palette, now you have the the option to use the button in the sidebar. This is what it looks like:

sidebarRibbon

Usage of moving rules

Important note 1: The text is case sensitive.

Important note 2: Use the "/" character to separate folders.

Writing Regex: The best tool for writing regex is Regex101 (https://regex101.com/)

Examples without regex

Lets imagine you have three files called Scroll 1, Scroll 2 and Scroll 3. Such as you can see below:

BeforeBasicScrollRule

After you install the plugin, you can create a rule to move all files that start with "Scroll" to the "Scrolls" folder. The rule would look like this:

BasicScrollRule

This will then create a folder called "Scrolls" and move all files that start with "Scroll" to that folder. The end result will look like this:

BasicResult

Example with the usage of regex and groups

Important note: The regex flavor used in this plugin is the ECMAScript(Javascript) flavor. The biggest difference between ECMAScript and PCRE2 is that {} brackets require the first value to be something ({0,1} -> zero or one of), while in PCRE2 it can be empty ({,1} -> zero or one of).

Imagine that you wanted to sort each scroll by its number into a separate folder. You could use the following regex to achieve that:

RegexGroupingScrolls

This will then create a folder for each scroll number and move the respective files to the correct folder. The end result will look like this:

RegexGroupingResult

Usage of exclusion rules

The exclusion rules are used to exclude files and folders from being moved. They go above the moving rules and are used to filter out files and folders that you don't want to be moved.

They syntax is the same as the one used for the moving rules but here you can find some exaples of how to use them anyway:

Example without regex

Lets imagine you have some creatures you want to move into folders like this. The list of creatures looks like this:

ExclusionExample1Before

And the rules you want to apply to them look like this:

rulesToApplyRats

After moving them you are left with this:

Example1Sorted

And now you are thinking "Damn, despite all that rage, those are still rats in a cage..." And because you saw how angry the rats were, you decided you don't want to include them in further sorting. Therefore, a rule would look like this:

ExcludedRat

And the result would look like this:

RatsUntrapped

Example with regex

I don't have any funny examples for this one, but I thought it could be useful to have the opportunity to exclude files and folders using regex as well.

Let's imagine you are moving the following files:

SystemFiles

And you decided you want to exclude those that have numbers as a suffix. Then your rules can look like this:

SystemRules

And the result would look like this:

SystemResult

A sidenote for this is that regex can by default be used to manage exclusions as well. So the current example of exclusion could have been handled with a slight change to the moving rule as well. The rule would looks like this "System [^\d\W]*" and the result would be the same.

Requesting features and reporting issues

If you want to request a feature or report an issue, please do so by creating an issue in the issues tab of this repository. In case you for some reason want to contact me directly, you can do so by sending me an email which is displayed in my github profile or via LinkedIn which is also displayed in my github profile.

Contribution

If you want to contribute to this plugin, you can do so by forking this repository and creating a pull request with your changes and an elaboration what they are and why. Thank you!

Future plans

  • Add excluded folder support
  • Add excluded file support
  • Add regex support for excluded folders and files (must support language accents like ñ, á, š, đ, こ, 猫, etc.)
  • Add time based execution of rule sorting
  • Exposing the move files button to the left toolbar
  • Exposing the move files to the commands accessible via command palette
  • Add import and export of rules
  • Add a file like .gitignore which contains all the moving rules (i am assuming the list can grow quite big for some people)
  • Auto tagging of moved files with the destination folder name (last folder in the path)