[Solved] Cleaning up empty folders on /disk*/ shares


Go to solution Solved by weirdcrap,

Recommended Posts

So because I'm an idiot I started a run of the unbalance plugin to move files off a drive so i can drop it from the array, then had to stop it because I included a disk I didn't mean to.

 

rsync created empty directories on the destination disks first so I now have a bunch of empty folders on the /mnt/disk* shares that don't correspond to the actual location of the data. I would like to delete the empties but am looking for a sanity check to make sure my methodology is sound and I'm not going to break things.

 

https://www.reddit.com/r/unRAID/comments/9chbca/user_share_splitting_and_clean_up/

FIND:
for i in {1..6};   do find /mnt/disk$i/ShareName -type d -empty -print; done

FIND & DELETE:
for i in {1..6};   do find /mnt/disk$i/ShareName -type d -empty -delete; done

This seems promising, works on the share level, and can be scaled across all the disks in the array.

 

Can anyone foresee any problems with running one of the above commands and clearing out the empty folders on a share by share basis? I figure by working at the share level I avoid accidentally deleting a top level share that may be empty for whatever reason.

 

 

EDIT: Well I gave it 48 hours and I couldn't come up with any negative effects so I went for it. It doesn't seem to have had any ill effects, no missing data, etc. Consider this solved.

Edited by weirdcrap
  • Like 5
Link to comment
  • weirdcrap changed the title to [Solved] Cleaning up empty folders on /disk*/ shares
  • 1 year later...

Hey! I have the same issue. I'm trying to break the habit of using Unbalance, but I've been using it for a while now and accumulated a lot of empty folders.

 

Since running that, any issues? Just always want to be extra cautious about doing any scripted deleted commands.

Link to comment
  • Solution
15 hours ago, s449 said:

Hey! I have the same issue. I'm trying to break the habit of using Unbalance, but I've been using it for a while now and accumulated a lot of empty folders.

 

Since running that, any issues? Just always want to be extra cautious about doing any scripted deleted commands.

I had no problems with the commands above that I can recollect. Just be sure to run FIND before you run FIND & DELETE to make sure you aren't getting anything included you don't want.

Edited by weirdcrap
  • Like 1
Link to comment
  • 2 weeks later...
On 7/13/2021 at 7:41 PM, weirdcrap said:
do find /mnt/disk$i/ShareName -type d -empty -print; done

Hi, I can't get this command to work. It says syntax error near unexpected token `do' 

 

In my case I typed do find /mnt/disk$6/Movies T-NET Server -type d -empty -print; done and then pressed enter.

 

What am I doing wrong?

Link to comment
11 hours ago, ChatNoir said:

I would guess that you probably need some kind of quotation marks if your share name has a space in it.

Not sure if it's 'quotation mark' or "quotation mark" or something else as I am not very comfortable with linux command line myself.

Yes If you have any spaces in your share name you need to either escape them or wrap the share name in quotes.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.