// GK Importer: drop a folder path that contains JSON items exported from Foundry and import them. (async () => { const dir = await new Promise(resolve => { new Dialog({ title: "GK Importer — pick folder URL or paste path", content: `
Paste a data path (e.g. /worlds/your-world/foundry/items)
`, buttons: { ok: { label: "Import", callback: html => resolve(html.find('input[name="path"]').val()) }, cancel: { label: "Cancel", callback: () => resolve(null) } }, default: "ok" }).render(true); }); if (!dir) return; const response = await FilePicker.browse("data", dir); const files = response.files.filter(f => f.endsWith(".json")); for (const f of files) { try { const json = await (await fetch(f)).json(); if (json.type && (json.name || json.label)) { if (!json.name && json.label) json.name = json.label; await Item.create(json); } } catch (err) { ui.notifications.error(`Import failed for ${f}: ${err.message}`); } } ui.notifications.info("GK Import complete."); })();