ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Is there such a tool to remove folder with 1 item

<< < (2/2)

AbteriX:
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

-imtrobin (February 21, 2010, 11:22 PM)
--- End quote ---

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:
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....

Navigation

[0] Message Index

[*] Previous page

Go to full version