Sign in to follow this  
Followers 0

Can autoit search a drive & delete empty folders?

13 posts in this topic

Posted

Can autoit search a drive & delete empty folders?

Share this post


Link to post
Share on other sites



Posted

No ?

Share this post


Link to post
Share on other sites

Posted

Removes (deletes) a directory.

RMDIR [/Q] [drive:]path

RD [/Q] [drive:]path

    /S      Removes all directories and files in the specified directory

            in addition to the directory itself.  Used to remove a directory

            tree.

    /Q      Quiet mode, do not ask if ok to remove a directory tree with /S

So...

$folder = '"C:\my folder"'
Run(@ComSpec & " /c rmdir /S /Q " & $folder, "", @SW_HIDE)

Share this post


Link to post
Share on other sites

Posted

That would just delete C:\my folder right ?

I need to search the whole c drive and remove any empty folders it finds.

Share this post


Link to post
Share on other sites

Posted

Bah, sorry. I'm not reading properly today :ph34r:

You could probably code AutoIt to do that, but I found a nifty one by using a google search that might be very helpful.

Share this post


Link to post
Share on other sites

Posted

Yes I found them too . all want the money . lol

Share this post


Link to post
Share on other sites

Posted (edited)

I found this one that seems to work .

http://www.snapfiles.com/get/rmempty.html

Can you show me how I can add the drive letter in with a input box .

Run(@ComSpec & " /k RMEMPTY.EXE C:\")

Right now I have it hard coded in .

Edited by bobheart

Share this post


Link to post
Share on other sites

Posted

why not...

$drive = FileSelectFolder("Select drive or folder to remove empty folders from","",0)
Run(@ComSpec & " /k RMEMPTY.EXE " & $drive)

untested, but here you go.

Share this post


Link to post
Share on other sites

Posted

Thank you that was perfect ..

Share this post


Link to post
Share on other sites

Posted

I don't suppose FileGetSize could have worked here too?

ie

if Filegetsize($myfolder) = 0 then filedelete($myfolder)

or whatever.. (didn't test this.. but just a thought)

Share this post


Link to post
Share on other sites

Posted

I don't suppose FileGetSize could have worked here too?

ie

if Filegetsize($myfolder) = 0 then filedelete($myfolder)

or whatever.. (didn't test this.. but just a thought)

If you could show a little more code so I could try it . then i could get rid of the other exe .

Share this post


Link to post
Share on other sites

Posted

yeah I just read the help file on it.. says "does not work on directories" for the FileGetSize function in autoit.. :(

but maybe a round about way? ie looking in the folder for *.* and if no results returned the delete..??

More complicated I think.. :ph34r:

Share this post


Link to post
Share on other sites

Posted

Ok i'll stick with what i found unless something comes along better .

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  
Followers 0