topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 7:01 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Is there such a tool to remove folder with 1 item  (Read 5765 times)

imtrobin

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 125
    • View Profile
    • Donate to Member
Is there such a tool to remove folder with 1 item
« on: February 21, 2010, 11:22 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

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Is there such a tool to remove folder with 1 item
« Reply #1 on: February 22, 2010, 08:52 PM »
if you want to remove empty folders, try Skrommel's DelEmpty.


AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
    • View Profile
    • Donate to Member
Re: Is there such a tool to remove folder with 1 item
« Reply #2 on: February 22, 2010, 09:09 PM »
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
    • View Profile
    • Donate to Member
Re: Is there such a tool to remove folder with 1 item
« Reply #3 on: February 23, 2010, 05:35 AM »
duh, i only saw 'emptyfolder' and missed the tree hierarchy totally.. :o

imtrobin

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

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Re: Is there such a tool to remove folder with 1 item
« Reply #5 on: February 24, 2010, 06:44 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


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

imtrobin

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 125
    • View Profile
    • Donate to Member
Re: Is there such a tool to remove folder with 1 item
« Reply #6 on: February 24, 2010, 08:36 AM »
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....