NewDisplayName Posted July 12, 2018 Share Posted July 12, 2018 (edited) I want to remove all directorys after /mnt/user/1/this if its empty so i use find /mnt/user/downloads/completed/this/ -type d -empty -exec rmdir {} \; mkdir /mnt/user/downloads/completed/this in user scripts, i mkdir, bc it deletes "this" also, but should only remove the dirs AFTER "this". It works, but it is problematic for unraid in someway? (i dont think so) Or is there a way to first only delete any folders AFTER "this" and keep "this", even if its empty? BTW. "this" is a user share Edited July 12, 2018 by nuhll Quote Link to comment
NewDisplayName Posted July 13, 2018 Author Share Posted July 13, 2018 (edited) Anyone know if its problematic that i remove a user share directory and recreate it every hour? (or know a way i can edit this script so it doesnt delete this Edited July 13, 2018 by nuhll Quote Link to comment
NewDisplayName Posted July 13, 2018 Author Share Posted July 13, 2018 Hmm, i "fixxed" it by touching a temp file before running the "delete empty folders script" in the folders i want to keep. Quote Link to comment
pwm Posted July 13, 2018 Share Posted July 13, 2018 2 hours ago, nuhll said: Hmm, i "fixxed" it by touching a temp file before running the "delete empty folders script" in the folders i want to keep. This is a quite common trick in use. Same as checkout of source code from repositories often may check out place-holder files just to auto-create required directories. You can also consider doing find /mnt/user/downloads/completed/this/* to make find run on the entries in the this/ directory instead of running on this/ itself. 1 Quote Link to comment
NewDisplayName Posted July 14, 2018 Author Share Posted July 14, 2018 As always, thanks! So i know im not doing something stupid, again. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.