Bulk change folder assets


#1

I’ve uploaded loads of images and used them in content items already.

But now I would like to rearrange the folder structure of the assets I have, so it is more ordered in the Cockpit UI.

Is there any way to achieve this?


#2

Hey @maartenhurkens, never tried but would say the following approach:

  1. Create in advance the new folder structure.
  2. Have a mapping between old and new folder structure, using folder ids e.g.
    $folderMapping["oldId" => "newId", "5c360fe3164bfc007e40dbb2" => "5c360fe3164bfc007e40daaa]
    You can build a Cockpit CLI command that loads all assets, and for each one, change the folder value (using the mapping array) and save the asset again.
    And after that you probably need also to update all collections (the folder id is also saved on the asset fields in the collection)