Using Quick Add to Archive Monthly Notes

What I’m trying to do

I’m trying to write a simple (not for me) script that I can run every month to archive the notes that were created that month.

I’ve boiled it down to the following steps:

  • Ask question “What month are you archiving?” - I will refer to this as “Response 1”
  • Rename folders called Current-Incidents and Current-Requests inside Tickets/“Response 1” to Incidents and to Requests
  • Create a folder inside Tickets/“Response 1” named Attachments
  • Move all files inside another folder also called Attachments but with path Attachments to the new Attachments folder except the files that are linked to by notes in the Tickets/In Progress folder
  • Ask question “What year will this be archived under?” - I will refer to this as “Response 2”
  • Move the Tickets/“Response 1” folder to Archive/“Response 2”
  • Ask question “What month are you starting?” - I will refer to this as “Response 3”
  • Create a new folder called “Response 3” inside the Tickets folder with sub-folders Current-Incidents and Current-Requests
  • Echo a reminder saying "Don’t forget to update the Metrics!!!

Things I have tried

To be honest I don’t really know. I have 0 or negative coding knowledge and after googling for a lot of hours on the last couple of days I started with a collage of stuff I found and started debugging and trying to fix all the errors shown in the console and I’m stuck with

async function main() {
    const month = await
      .inputPrompt('What month are you archiving?');
    // Rename folders
    // Create new Attachments folder
    // Move all files from old Attachments folder to new Attachments folder
    const inProgressNotes = await
      `Tickets/${month}/In Progress/.obsidian/attached_files.json`
    const inProgressLinks = Object.keys(JSON.parse(inProgressNotes));
    const oldAttachmentsFiles = await
    for (let i = 0; i < oldAttachmentsFiles.length; i++) {
      const file = oldAttachmentsFiles[i];
      if (!inProgressLinks.includes(`../Attachments/${file}`)) {
    const year = await
      .inputPrompt('What year will this be archived under?');
    // Move folder to Archive
    const newMonth = await
      .inputPrompt('What month are you starting?');
    // Create new folder and sub-folders
    console.log("Don't forget to update the Metrics!!!");

which I’m pretty sure that is probably 99% wrong.

Any help is seriously appreciated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.