Create files based in a list file in MD

Hey everyone,

I’m totally amazed by how powerful Obsidian is! I’ve just started using it and I’ve been diving into the Obsidian Projects plugin. I wanted to find an easier way to create notes, so I asked ChatGPT for some help, and it led me to a cool trick.

By opening the developer panel with CTRL + SHIFT + I and running the following code on console:

const folderPath = "./FolderPath"; // Specify your folder name
const fileList = await app.vault.adapter.read("./your/folder/path/list.md"); // Read your text file
const fileNames = fileList.split("\n"); // Split into an array of names

for (const fileName of fileNames) {
    const trimmedName = fileName.trim();
    if (trimmedName) {
        await app.vault.create(`${folderPath}/${trimmedName}.md`, ""); // Create empty Markdown files
    }
}

This script reads a list of filenames from a text file and creates empty Markdown files in the specified folder. It’s a huge time-saver!

Just wanted to share this in case it helps anyone else. Obsidian really is amazing!

of course you can save this to a templater js file and re-use it (name the script so that you can easily remember having it)

otherwise these kind of operations are usually better to do with python (with obsidian open or closed, depending on the scale of operations)

but i admit that obsidian is amazing and for a quick snippet the dev panel can be used (i used it just yesterday myself)

1 Like