ImaginaryProgramming / obsidian-vault-transfer

Transfers a note from one vault to another.
GNU General Public License v3.0
29 stars 5 forks source link

[FEAT]: Date variable in output + path replacement #10

Closed Mara-Li closed 8 months ago

Mara-Li commented 9 months ago

I wanted a way to archive by date my files, and change some path to another. For example, I wanted to move my 20. AREA/Concepts/Personnages into Roleplay/{{dateOfCreationFile}}/

I allow to use a frontmatter key. If a folder is moved, it can use a folder note (file with same name inside or outside the folder) or inside index note. If the date doesn't exists, it will take a fallback based on the creation or modification date.

In case a date is undefined, the default date will be the today date.

ImaginaryProgramming commented 8 months ago

Hi @Lisandra-dev, thank you for the code contribution! I'm not certain I fully understand what this feature aims to accomplish, but I'm thinking it may be out of scope for what this plugin does. My understanding is that you want to transfer a note to another vault, using a date property from the frontmatter to determine the path. Is that correct?

If this is the case, maybe a different flow would be sufficient? I'd like to avoid feature creep for this plugin, as it makes it harder to figure out how to use it for simple cases. Perhaps you could transfer your notes to an Unsorted folder, and later use the QuickAdd plugin to organize the notes? I put together a rough userscript to sanity check this idea, although it's not complete. You can install it following these video instructions.

const TARGET_PATH = "Target path";

module.exports = {
    entry: async (quickAdd, settings) => {
        const currentFile = quickAdd.app.workspace.getActiveFile();
        const targetPath = settings[TARGET_PATH];

        // TODO Pull date from frontmatter
        const date = quickAdd.quickAddApi.date.now();

        // TODO Create folder if it doesn't exist
        await quickAdd.app.fileManager.renameFile(
            currentFile,
            `${targetPath}/${date}/${currentFile.name}`
        );
    },
    settings: {
        name: "Move file by date",
        options: {
            [TARGET_PATH]: {
                type: "text",
                defaultValue: "Moved by date/",
                description: "Target path to move the file to.",
            },
        }
    },
};

Would this other flow work for you?

Mara-Li commented 8 months ago

Hello! It's not a problem if it's out of the scope of the plugin. I will carry my own fork, then!

I use the plugin more like an exporter to folder than a real vault (I never open my archive vault in Obsidian, only some file in VSCode for example).

Thanks for this plugin and have a good day :)