Jump to content
Sign in to follow this  
zvd

Delete empty directories

Recommended Posts

Does anyone have a script or suggestions on how to write one that would search for all empty directories/subdirectories and delete them?

Share this post


Link to post
Share on other sites
Guest checkist

Well, ultra-ugly, super-inefficient method is..

cmd /c Xcopy [source] [temporary target] /s /a/h

delete [source], and rename [temporary target] directory to original [source]

Xcopy's '/s' switch recursively copies "Nonempty" subdirectories.

It may work. but it's too slow for any practical use.

(In short, this is useless)

Share this post


Link to post
Share on other sites

Hi,

there are various recursive FileSearch" utilities on the forum.

At least one of them searches for directories too;

FileSearch gafrost

When you get to

              $hFile = FileFindFirstFile($szRoot & "*.*")

              If $hFile >= 0 Then

I imagine you could do an "else" (if no files ie empty), delete the current directory, or add name to a file for checking and deleting at the end from the file? -Interested to hear if you get it going!

Randall

Share this post


Link to post
Share on other sites
Here is a script example that can delete files older than and remove empty directories... Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...