<%*
const listName = await tp.system.suggester(["Groceries", "Health", "Household"], ["Groceries", "Health", "Household"])
let tempResult = "";
let num = 0;
const {update} = this.app.plugins.plugins["metaedit"].api;
const {getPropertyValue} = this.app.plugins.plugins["metaedit"].api;
let itemList = await getPropertyValue(listName, tp.file.find_tfile("@Shopping list"))

for (let i = 0; i < itemList.length; i++) {
let amount = itemList[i].split(" ")[0] + " " + num.toString();
let radicale = itemList[i].replace(itemList[i].split(" ")[0] + " " + itemList[i].split(" ")[1], "");
if (!i) {
tempResult = amount + radicale
} else
tempResult = tempResult + ", " + amount + radicale
}
}

await update(listName, tempResult, tp.file.find_tfile("@Shopping list"));

%>

