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

<p>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. </p>

<p>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!</p>

<p>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.</p>

CC BY-SA 3.0
2016-04-19T01:18:00.533Z
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
CC BY-SA 3.0
2016-04-18T13:55:44.043Z
2016-04-18T17:24:01.803Z
2016-04-18T17:24:01.803Z
Andris Sevcenko
<p>I have <code>{status}/{category}/{slug}</code> 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. </p>

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

CC BY-SA 3.0
2016-04-15T21:04:15.057Z
{category} is an entry type, so its {entry.first.title} if that info helps at all.
nightarrow85
<assets><upload><subfolder>
Dynamic Subfolders leaving empty folders behind
# Dynamic Subfolders leaving empty folders behind

(Asked by: username_0 on 2016-04-15)

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?

**Tags:** assets, upload, subfolder
> **Comments:**
> **username_0**: {category} is an entry type, so its {entry.first.title} if that info helps at all.  

---

## 1 answers

### Answer by username_1 on 2016-04-18. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_0**: 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.  

---

