Jump to content

Recommended Posts

Posted

I'm trying to empty my Temp dir that contains lots of files, i use for example the filedelete(C:\windows\temp\*.*) function and it starts deleting but some files are being used by windows , so filedelete fails and immediatly stops.

Is their any way to force filedelete not to stop if this happens ?

I know it's possible to use batch commands and vbscripts but i want to use it with autoit.

Posted

delete them individually by using a complicated FileFindFirstFile / FileFindNextFile recursive function... It is possible... not fun...

Lar.

<{POST_SNAPBACK}>

Just made a UDF.

DeleteFilesUDF.au3

ClearTemp.au3

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Posted (edited)

Brilliant coding there Solid Snake!

I tested this on NT and it deleted the files and also files within the folders. Unfortunately it leaves the folders. Anyway that the folders can be deleted too? I know that the folders are empty and don't take up any room, but it is good to delete all folders and leave the 'Temp' folder and 'Temporary Internet files' folder intact (else Windows will complain).... Also I checked and there are no processes blocking the deletion of the 'empty folders' and I can delete them via Explorer easily.

Edited by dash007
Posted

This should do the trick.

If StringInStr(FileGetAttrib($file), "d") Then
   DirRemove($file, 1)
Else
   FileDelete($file)
EndIf

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Posted

Brilliant coding there Solid Snake!

I tested this on NT and it deleted the files and also files within the folders. Unfortunately it leaves the folders. Anyway that the folders can be deleted too? I know that the folders are empty and don't take up any room, but it is good to delete all folders and leave the 'Temp' folder and 'Temporary Internet files' folder intact (else Windows will complain).... Also I checked and there are no processes blocking the deletion of the 'empty folders' and I can delete them via Explorer easily.

<{POST_SNAPBACK}>

Thanks for the feedback.

About it not deleting folders. It seems to delete them as long as they are empty. It won't however delete a folder that has an in use file in it which I don't think is possible.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...