au3scr Posted February 21, 2008 Share Posted February 21, 2008 Hi how to do script that deletes all files in temp dir? is there any command to delete all files? there are also some files that you cant delete (prodected by system) so script should skip these. Link to comment Share on other sites More sharing options...
Swift Posted February 21, 2008 Share Posted February 21, 2008 DirRemove(@TempDir & "\", 1) Link to comment Share on other sites More sharing options...
AL3X Posted February 21, 2008 Share Posted February 21, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
Swift Posted February 21, 2008 Share Posted February 21, 2008 Yep. Link to comment Share on other sites More sharing options...
NELyon Posted February 21, 2008 Share Posted February 21, 2008 Wont this remove the entire folder of temporary files ? :SWhich is regenerated when it is rewritten too, but this time when it is rewritten, it is empty Link to comment Share on other sites More sharing options...
AL3X Posted February 21, 2008 Share Posted February 21, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
NELyon Posted February 21, 2008 Share Posted February 21, 2008 (edited) Untested: #Include <File.au3> $dir = @TempDir $files = _FileListToArray($dir) For $i = 1 to UBound($files) - 1 FileDelete($files[$i]) Next Edited February 21, 2008 by Senton-Bomb Link to comment Share on other sites More sharing options...
AL3X Posted February 21, 2008 Share Posted February 21, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
au3scr Posted February 21, 2008 Author Share Posted February 21, 2008 thank you Link to comment Share on other sites More sharing options...
Greenhorn Posted February 21, 2008 Share Posted February 21, 2008 (edited) Perhaps this are files which are still in use of some programs or processes !It's not recommended to delete them while the process take use of the files.i.e. my Firewall uses some temporary files in my Temp folder and I don't think that it would be a gain if I force to delete it, isn' t it !?Maybe the other files without importance you can't delete, are set to read only, so test to set the attributes to writable ...Run before the DirRemove a FileSetAttrib(.., .., 1) with the '1' parameter at the end.For subfolders you have to create a loop ...GreetzGreenhornEdit: Look at here ...http://www.autoitscript.com/forum/index.ph...temporary+files; Author: MadBoy #Include <File.au3> ;_DirRemoveContents(@UserProfileDir & '\Local Settings\Temporary Internet Files\Content.IE5') ;_DirRemoveContents(@TempDir) Func _DirRemoveContents($folder) Local $list_of_contents, $status $list_of_contents = _FileListToArray($folder) If IsArray($list_of_contents) Then If StringRight($folder, 1) <> "\" Then $folder = $folder & "\" If @error = 1 Then Return 1 ; No Files\Folders Found For $a = 1 To $list_of_contents[0] FileSetAttrib($folder & "\" & $list_of_contents[$a], "-RASH") If StringInStr(FileGetAttrib($folder & $list_of_contents[$a]), "D") Then $status = DirRemove($folder & $list_of_contents[$a], 1) Else $status = FileDelete($folder & $list_of_contents[$a]) EndIf Next Else Return 2 ; Directory doesn't exists EndIf EndFunc ;==>_DirRemoveContents Edited February 21, 2008 by Greenhorn Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now