+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, find and delete empty folders in Coding and Web Development; I'm looking for a script that will recursively search and delete any empty folders. Preferably bash or perl. I might ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,476
    Thank Post
    1,305
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    198

    find and delete empty folders

    I'm looking for a script that will recursively search and delete any empty folders. Preferably bash or perl. I might be able to do it myself in bash, but Im not sure how to check for the empty folder?

  2. #2

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,161
    Thank Post
    95
    Thanked 318 Times in 260 Posts
    Blog Entries
    4
    Rep Power
    111
    Not really my area, having only limited experience of Linux (though I do use it as my home operating system) but this post might help you with the bash script.

    UNIX BASH scripting: How to check folder size in linux - Linux Newbie

  3. #3


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    338
    bit of a bodge, rmdir should error if the dir isn't empty

    Code:
    find . -type d -exec rmdir {} \;

  4. Thanks to CyberNerd from:

    RabbieBurns (9th February 2009)

  5. #4

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,476
    Thank Post
    1,305
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    198
    that works, thanks

SHARE:
+ Post New Thread

Similar Threads

  1. Empty files and folders on a shared area
    By ranj in forum Windows
    Replies: 6
    Last Post: 6th January 2009, 12:11 PM
  2. Script to delete specific folders
    By Baasha_Bhai in forum Scripts
    Replies: 8
    Last Post: 2nd July 2008, 10:41 AM
  3. VB script to delete certain folders
    By PTD in forum Scripts
    Replies: 7
    Last Post: 4th June 2008, 12:30 PM
  4. Script to delete certain folders
    By Pumaedition in forum Scripts
    Replies: 4
    Last Post: 22nd April 2008, 10:08 PM
  5. Wanted: VBScript to delete folders from C:
    By timbo343 in forum Scripts
    Replies: 7
    Last Post: 7th February 2008, 11:50 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •