Answers.Body: <p>I would probably do this in two steps:</p>
  <ol>
  <li>Create a twig file formatted as a CSV that outputs the category and asset id's, i.e.</li>
  </ol>
  <pre><code>AssetId, Category&lt;br&gt;
  {% for entry in entries %}
  {{ entry.asset.one().id }}, {% for category in categories %}{{ category.id }}{% if not loop.last %}-|-{% endif %}{% endfor %}&lt;br&gt;
  {% endfor %}
  </code></pre>
  <ol start="2">
  <li>Use <a href="https://plugins.craftcms.com/feed-me" rel="nofollow noreferrer">feed me</a> to re-import the categories onto the assets using the CSV.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-23T10:04:40.523Z
Answers.Text: Clever! Will try this, thank you!
Answers.UserDisplayName: evvvvritt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-20T22:00:00.767Z
Answers.LastActivityDate: 2020-10-20T22:00:00.767Z
Answers.UserDisplayName: dmatthams
Body: <p>Is it possible to migrate content like categories from an entry to an asset easily?</p>
  <p>Each entry has an image asset and I'd like to move all the categories on the entry to the asset.</p>
  <p>Would this require a SQL operation or is there any easier way?</p>
  
Tags: <migration>
Title: Migrating categories from Entry to Asset
ThreadText: # Migrating categories from Entry to Asset
  
  (Asked by: username_0 on 2020-10-19)
  
  Is it possible to migrate content like categories from an entry to an asset easily?
  
  Each entry has an image asset and I'd like to move all the categories on the entry to the asset.
  
  Would this require a SQL operation or is there any easier way?
  
  **Tags:** migration
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-10-20. Score: 2 | Accepted answer
  
  I would probably do this in two steps:
  
  1. Create a twig file formatted as a CSV that outputs the category and asset id's, i.e.
  
  ```
  AssetId, Category<br>
  {% for entry in entries %}
  {{ entry.asset.one().id }}, {% for category in categories %}{{ category.id }}{% if not loop.last %}-|-{% endif %}{% endfor %}<br>
  {% endfor %}
  
  ```
  
  2. Use [feed me](https://plugins.craftcms.com/feed-me) to re-import the categories onto the assets using the CSV.
  
  > **Comments:**
  > **username_0**: Clever! Will try this, thank you!  
  
  ---
  
  