0

I'm using Assets almost since day one. And 7 years ago was, well, a whole other time. ;-) Many things changed, but the Assets-Configuration on one quite large project stayed the same since. Those days we configured many individual Upload-Folders. Nowadays, we actually only need a few of them. So we want to «clean up» our assets and upload-dirs.

Is there a easy way to do that? There are 9 different upload-dirs we do use with Assets. We now would like to merge 8 of them to one, so we would have only two dirs left.

What's the easiest way to do that? I guess I have to move the files on the server and re-index everything in the controlpanel, and somehow update all the filedirs in the DB … right? But how? :see_no_evil: :-)

1 Answer 1

1

Do you plan to continue using Assets? If you do you probably can achieve all this simply by dragging / dropping images within the Assets UI.

If you plan to eliminate Assets, you cannot simply change the field type from Assets to File to migrate. Assets does not store information about where an image is in the Asset field for an entry (it stores that in a separate assets table) - just the name of the image / file. But EE does (it puts {FileDir_X} ahead of the filename, where X is the ID of the upload directory). So if you are moving from one field type to the other you need to add this information to the image names from Assets.

Doing this requires some excursion that lets you mess directly with the EE database (either php or direct SQL would work). Probably SQL is easiest for a one-off migration.

So you end up with something like this:

  • Consolidate all the images in the 'top-level' folder of the filedirs you want to keep, and keep a record of which of the upload directories each image has ended up in (if you leave them in sub-folders, EE won't be able to see them via the file field type).
  • Create the new image fields in your EE channels for the images
  • Generate some SQL that copies the name of the image file from the Assets field to the appropriate new EE Image field and prefixes with the appropriate filedir ID tag. Suggest you do this on a field by field basis.
  • Test the results.

As ever, make sure you back up everything, and do this work on a development server to be sure you have got it down before you work on the live one.

1
  • OMG … there's drag-and-drop in Assets … :rolling_eyes: … and this after 7 years of daily use :-D this makes all of that way easyier, most of the files I can simply drag-and-drop to the consolidated filedir – and for the rest I might have to update the DB. *THANK YOU, @jcogs.eecms *
    – albuvee
    Commented Jul 7, 2018 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.