[OpenIndiana-discuss] Deleting empty directories
Michelle
michelle at msknight.com
Wed Aug 2 21:45:28 UTC 2023
Thanks Tim.
That's very useful learning info. I didn't know about the --prune-
empty-dirs option.
I guess I'm guilty of cribbing what I need from the internet and never
learning things properly.
Oh for the time to do all the things I would like to!
Many thanks,
Michelle.
On Wed, 2023-08-02 at 16:32 -0500, Tim Mooney via openindiana-discuss
wrote:
> In regard to: [OpenIndiana-discuss] Deleting empty directories,
> Michelle...:
>
> > Basically, I extract all the flac files out of my main music
> > collection, to a separate location, (using rsync) and then I have
> > to
> > delete the empty directories that rsync has created.
>
> You could use '--prune-empty-dirs' with rsync.
>
> > I managed the first part, no problem. However, it's the deleting of
> > empty directories that is causing me trouble.
> >
> > The Linux command is...
> > find /mnt/jaguar/users/michelle/FlacCopy -type d -empty -delete
> > ...however the OI version of find doesn't support -empty
>
> No, but it supports '-depth', which means you can
>
> find /mnt/jaguar/users/michelle/FlacCopy -depth -type d \
> -exec rmdir {} \; 2>/dev/null
>
> That will fail *a lot*, but the error messages are thrown away and
> the
> empty directories will be deleted.
>
> or if you have GNU fileutils installed (so 'grmdir' exists)
>
> find /mnt/jaguar/users/michelle/FlacCopy -depth -type d \
> -exec grmdir --ignore-fail-on-non-empty {} \;
>
> -depth is important for either of these to work.
>
> The best part of both of those is that you can insert 'echo' between
> '-exec' and the start of the command, and it will show you what it's
> going to do without doing it. If you like what you see, just remove
> the
> 'echo'.
>
> > I've tried to install gfind, but that doesn't appear to be
> > available.
>
> Someone else already answered with the correct pkg FMRI.
>
> Tim
More information about the openindiana-discuss
mailing list