{
  "name": "Migrate icons of actor",
  "type": "script",
  "scope": "global",
  "author": "6SdI10VpXHcBvx2J",
  "img": "icons/svg/card-joker.svg",
  "command": "const tokens = canvas.tokens.controlled;\n\nif (tokens.length == 1 ){\n  await updateIcons(tokens[0]);\n} else {\n  ui.notifications.info(\"No Tokens or too many tokens were selected\");\n}\n\nasync function updateIcons(token){\n  if (!token.isOwner) {\n    ui.notifications.info(\"You don't own that token\");\n  }\n  let actor = token.actor;\n  \n  \n  const items = actor.items.filter(e => e.type == \"ability\" || e.type == \"virtue\" || e.type == \"flaw\");\n  ui.notifications.info(`${items.length} items found`);\n\n  let updatedItems = []\n  for (let it of items) {\n    if (it.img == CONFIG.ARM5E_DEFAULT_ICONS[it.type] ||\n    it.img === \"icons/svg/mystery-man.svg\" ||\n    it.img === \"icons/svg/item-bag.svg\") {\n        \n      console.log(it.name);\n      let itemData = {_id : it._id, img : CONFIG.Item.systemDataModels[it.type].getIcon(it)};\n      updatedItems.push(itemData);\n    }\n  }\n  let updated = await actor.updateEmbeddedDocuments(\"Item\",updatedItems);\n\n  ui.notifications.info(`${updated.length} items updated`);\n  \n}",
  "ownership": {
    "default": 0,
    "ErQ613O32LNYb71L": 3,
    "6SdI10VpXHcBvx2J": 3
  },
  "flags": {
    "core": {}
  },
  "_stats": {
    "compendiumSource": "Macro.FL254GFtSFOTzooP",
    "duplicateSource": null,
    "coreVersion": "13.351",
    "systemId": "arm5e",
    "systemVersion": "2.3.2.7",
    "createdTime": 1731268016499,
    "modifiedTime": 1743316271731,
    "lastModifiedBy": "xMd6zrGNn4dbQYey",
    "exportSource": null
  },
  "folder": "qGZgdsZ3cZpILlVt",
  "_id": "Ruj42ho3vlQDyczk",
  "sort": 400000,
  "_key": "!macros!Ruj42ho3vlQDyczk"
}
