469,323 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Delete Empty Directory

hi, i am new to perl
I am looking for a simple script to delete non empty folder.
Remove Directory and File(s)
plz help me...
Apr 9 '07 #1
5 5821
4,059 Expert 2GB
perldoc File::Path module
Apr 9 '07 #2

Use the following Code

use File::Find;

That's it
Apr 9 '07 #3
Sorry the above code will delete the Empty Folders
Apr 9 '07 #4
ajay m
Thank you sir
Apr 10 '07 #5

File::Path removes everything. Not just non-empty directories.


While it is the inverted answer, you are running rmdir on EVERY filename, not just directories or even empty directories. Though That is quite valid as it does the required tests.

Now to try and answer for real...

To try and remove directories that are NOT empty, is tricky. A directory with a directory is technically not-empty. So by that criteria, you want to remove any directory that is more than 2 levels deep! That does not sound right.

So what exactly do you want?

Delete directories that contain files? Or just...
Delete all files and leave just the directory structure?

Basically what do you define as being not-empty?
Feb 4 '16 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Brian Cahill | last post: by
reply views Thread by Terry | last post: by
7 posts views Thread by Anil Gupte | last post: by
24 posts views Thread by biganthony via AccessMonster.com | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.