+ 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
    4,747
    Blog Entries
    6
    Thank Post
    1,015
    Thanked 427 Times in 272 Posts
    Rep Power
    141

    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. IDG Tech News

  3. #2

    Join Date
    Mar 2008
    Location
    Woking
    Posts
    2,094
    Blog Entries
    4
    Thank Post
    86
    Thanked 302 Times in 249 Posts
    Rep Power
    98
    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

  4. #3


    Join Date
    Jan 2006
    Posts
    6,457
    Thank Post
    324
    Thanked 740 Times in 557 Posts
    Rep Power
    201
    bit of a bodge, rmdir should error if the dir isn't empty

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

  5. Thanks to CyberNerd from:

    RabbieBurns (9th February 2009)

  6. #4

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    4,747
    Blog Entries
    6
    Thank Post
    1,015
    Thanked 427 Times in 272 Posts
    Rep Power
    141
    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, 01: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, 12:50 PM

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
  •