DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Delete specific folders in a directory hierarchy tree  (Read 6,154 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 563
Delete specific folders in a directory hierarchy tree
« on: November 23, 2021, 06:09 AM »
I've been searching for hours for an answer.  Such a simple thing.  Huge jumble of partial answers....

Given:  Large directory tree structure, folders with files, maybe some empty folders.

Challenge:  Move recursively throughout tree.  Delete all folders in entire tree that has in name "xyz".

There might be one such folder.  There might be one hundred.

Any thoughts greatly appreciated.

Nicholas Kormanik

(thanks @publicdomain, and others, for much help on many challenges)

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: Delete specific folders in a directory hierarchy tree
« Reply #1 on: November 23, 2021, 11:41 AM »
Easy to do with Everything https://www.voidtools.com/
For example if the start folder of the tree is "C:\tree" then you can list all its subfolders with "xyz" in the subfolder name with this search line. (The option "match path" in the menu "Search" must also be enabled.)
Code
"C:\tree\" xyz folder:
You can then select the subfolders in the results list and delete them, just like in File Explorer. Doing so will also delete any files within those subfolders, of course. If the subfolder name fragment you search for has spaces then quote enclose it e.g. "abc def".

3.png

This basic example can be modified for more complex searches, for example with regex pattern matching instead of a plain string.
« Last Edit: November 23, 2021, 11:53 AM by Nod5 »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 732
    • Participated in NANY Challenge Three Times
    • Linux User
Re: Delete specific folders in a directory hierarchy tree
« Reply #2 on: November 24, 2021, 04:42 AM »
Given:  Large directory tree structure, folders with files, maybe some empty folders.

Challenge:  Move recursively throughout tree.  Delete all folders in entire tree that has in name "xyz".

There might be one such folder.  There might be one hundred.

Hi Nick! nkTree coming:



Supports long paths via Win32 API library: 32000+ characters.

https://github.com/publicdomain/nktree

(I'm finally home & coding for the Public Domain :Thmbsup: November release -just some days to go)

(thanks @publicdomain Vic, and others, for much help on many challenges)

Having multiple community support is the best indeed!

(From my humble position, rest assured it's my pleasure, AMIGO :) )
« Last Edit: November 24, 2021, 04:54 AM by publicdomain »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 732
    • Participated in NANY Challenge Three Times
    • Linux User
« Last Edit: November 30, 2021, 03:08 PM by publicdomain »

Original address: https://www.donationcoder.com/forum/index.php?topic=51944.0