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?

  • {category} is an entry type, so its {entry.first.title} if that info helps at all. – nightarrow85 Apr 15 '16 at 21:04
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.

| improve this answer | |
  • 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. – nightarrow85 Apr 19 '16 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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