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: Is there such a tool to remove folder with 1 item  (Read 8,434 times)

imtrobin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 125
Is there such a tool to remove folder with 1 item
« on: February 22, 2010, 05:22 AM »
Hi I'm looking for a quick way to remove folders with only 1 item (the subfolder), but preserving the hierarching

e.g
folder1
  emptyfolder
    emptyfolder
      folderwithcontent1
        folderwithcontent2

Becomes:

folder1
  files from folderwithcontent1
    files from folderwithcontent2

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: Is there such a tool to remove folder with 1 item
« Reply #1 on: February 23, 2010, 02:52 AM »
if you want to remove empty folders, try Skrommel's DelEmpty.

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
Re: Is there such a tool to remove folder with 1 item
« Reply #2 on: February 23, 2010, 03:09 AM »
No help here, but I'll be interested to see how someone goes about this  :Thmbsup:

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: Is there such a tool to remove folder with 1 item
« Reply #3 on: February 23, 2010, 11:35 AM »
duh, i only saw 'emptyfolder' and missed the tree hierarchy totally.. :o

imtrobin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 125
Re: Is there such a tool to remove folder with 1 item
« Reply #4 on: February 23, 2010, 05:05 PM »
yes, most tools just remove empty folders only. they don't do what I want.

AbteriX

  • Member #520
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,150
Re: Is there such a tool to remove folder with 1 item
« Reply #5 on: February 24, 2010, 12:44 PM »
Hi I'm looking for a quick way to remove folders with only 1 item (the subfolder), but preserving the hierarching

e.g
folder1
  emptyfolder
    emptyfolder
      folderwithcontent1
         folderwithcontent2

Becomes:

folder1
  files from folderwithcontent1
     files from folderwithcontent2

To make this clear, do you mean:

Becomes:
folder1
  folderwithcontent1
      folderwithcontent2





e.g.
folder1
  emptyfolder
    emptyfolder
      folderwithcontent1
        folderwithcontent2

e.g. Step 1
folder1
  emptyfolder
    emptyfolder
    folderwithcontent1
      folderwithcontent2

e.g. Step 2
folder1
  emptyfolder
    emptyfolder
  folderwithcontent1
    folderwithcontent2

e.g. Step 3
delete all empty folders


That can be done with an script i think:
- get an array-list of all sub-folders

For Each folder in Array
  - go to each deepest sub-folder
    While parent != folder1
        - IF (my-parent-folder IS without files) THEN move this-folder-and-all-subfolder one hierarchy up 
        - go to parent
    Loop
Next

- then delete all empty sub-folders
Greetings, Stefan.

imtrobin

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 125
Re: Is there such a tool to remove folder with 1 item
« Reply #6 on: February 24, 2010, 02:36 PM »
Yes, that's the idea. It's not terribly difficult to do but I just don't have to time to do it (in C#). If I find more time for programing....

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