Delete empty files sub-folders when empty

Created on 9 October 2010, over 14 years ago
Updated 28 March 2025, 8 days ago

Drupal 7 & Token - Not deleting files attached to nodes stored in token path

I have a node called photo. Initially, it was set to store files at photos.

I then installed and implemented the token module. I set files to store at photos/[current-user:name]/[date:custom:Y]/[date:custom:m]/[date:custom:d]. Over this time, I of course uploaded sample photos to ensure that it was working. I used ftp to verify the location of the files, and once I had my own issues worked out the upload process seemed to work flawlessly.

My next task was to delete the nodes. That worked flawlessly. I verified that the files were deleted from the specified directory and sure enough - that was done too.

However, after that testing (over two days) - I ended up with two directory trees that were emply (and now useless), that would require a manual deletion. In my case...
.../files/photos/admin/2010/10/08
.../files/photos/admin/2010/10/09

Is that any way to automate this? If the directoy is still being used, obviously it should stay, but if the deletion removes the last item, then it should remove the directory as well. The corollary is that if the directory removal emties it's parent, it should be removed as well and so forth.

Thanks, Carolyn

✨ Feature request
Status

Closed: won't fix

Version

11.0 πŸ”₯

Component

file system

Created by

πŸ‡¨πŸ‡¦Canada Carolyn Marenger

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024