3

I have {status}/{category}/{slug} as the path for uploading photos. When the status changes on the entry, then the photos associated with that entry move to the correct folder.

However, it leaves behind empty {category}/{slug} folders in the {status} folder it used to sit in. I don't believe it did so when I tried {status}/{slug} -- is it possible to do this without leaving debris in the previous folders?

1
  • {category} is an entry type, so its {entry.first.title} if that info helps at all. Commented Apr 15, 2016 at 21:04

1 Answer 1

3

When Assets moves files around because of dynamic Assets folder changes, it does not remove empty folders.

On the surface it seems like a no-brainer - just check if the folder is empty and if so, then nuke it! But if you go deeper, it gets complicated.

Should the physical folder be removed as well? If not, then the next time you index Assets, the folder will be reinstated. If yes, then what to do if there are unindexed files in there? Remove anyway? That's destructive. Don't remove? Then that makes Craft behave differently based on something that is out of its scope. What would users want in this case? Who knows!

You see, it's a bit tricky especially in terms of what the users would expect out of that functionality, so we just instead decided to go with leaving empty folder, as the folder path changing should not be that often of an occurrence and does not set us up for complex support tickets down the road.

1
  • Thanks, I was having trouble seeing what was going on in a large assets library. It's a lot easier knowing for sure that the empty folders get left behind once the content moves. I'll have to avoid using changing data in folder names. Commented Apr 19, 2016 at 1:18

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.