dexter23 Posted January 24, 2008 Posted January 24, 2008 I want to delete some files with the same extension from one folder. I try this script but don't work #Include <File.au3> #Include <Array.au3> $path = "D:\Notes" $FileList = _FileListToArray($path, "*.txt") For $i = 1 To $FileList[0] FileDelete($path & "\" & $FileList[$i]) Next
Monamo Posted January 24, 2008 Posted January 24, 2008 I want to delete some files with the same extension from one folder. I try this script but don't work #Include <File.au3> #Include <Array.au3> $path = "D:\Notes" $FileList = _FileListToArray($path, "*.txt") For $i = 1 To $FileList[0] FileDelete($path & "\" & $FileList[$i]) Next Code's clean and works fine for me - Except for "Read-Only" files. If that ends up being the case with your files, take a look at FileSetAttrib() - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
dexter23 Posted January 24, 2008 Author Posted January 24, 2008 Sorry. I found the problem. The script works, but in that folder I have other folders which include files. The problem is to recurse in subdirectories.
randallc Posted January 24, 2008 Posted January 24, 2008 Sorry. I found the problem. The script works, but in that folder I have other folders which include files. The problem is to recurse in subdirectories.Hi, Use this UDF?; ; filedel.au3 #Include <FileListToArray.au3> #Include <Array.au3> $path = @ScriptDir $FileList = _FileListToArray($path, "*.txt",1,1) _arraydisplay($FileList) ;~ For $i = 1 To $FileList[0];~ FileDelete($path & "\" & $FileList[$i]) ;~ ConsoleWrite($path & "\" & $FileList[$i]&@LF) ;~ Next ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
weaponx Posted January 24, 2008 Posted January 24, 2008 @randallc you should avoid reposting attachments as often as possible. You should link directly to the main topic containing your scripts so there aren't a bunch of different versions floating around. This also prevents you from filling up your attachment space which I did a long time ago.
dexter23 Posted January 24, 2008 Author Posted January 24, 2008 Hi, Use this UDF?; ; filedel.au3 #Include <FileListToArray.au3> #Include <Array.au3> $path = @ScriptDir $FileList = _FileListToArray($path, "*.txt",1,1) _arraydisplay($FileList) ;~ For $i = 1 To $FileList[0];~ FileDelete($path & "\" & $FileList[$i]) ;~ ConsoleWrite($path & "\" & $FileList[$i]&@LF) ;~ NextoÝ÷ Ûú®¢×¶¸vØb±«¢+Ø%¹±Õ±Ðí¥±1¥ÍÑQ½ÉÉä¹ÔÌÐì(%¹±Õ±ÐíÉÉä¹ÔÌÐì((ÀÌØíÁÑ ôMÉ¥ÁÑ¥È((ÀÌØí¥±1¥ÍÐô}¥±1¥ÍÑQ½ÉÉä ÀÌØíÁÑ °ÅÕ½Ð쨹ÑáÐÅÕ½Ðì°Ä°Ä¤)½ÈÀÌØí¤ôÄQ¼ÀÌØí¥±1¥ÍÑlÁt(%¥±±Ñ ÀÌØíÁÑ µÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥±1¥ÍÑlÀÌØí¥t¤)9á with those 2 files provided, but nothing.
weaponx Posted January 24, 2008 Posted January 24, 2008 randallc's function name isn't _FileListToArray...its _FileListToArray3randallc example script:http://www.autoitscript.com/forum/index.php?showtopic=49396FileListToArray repository:http://www.autoitscript.com/forum/index.ph...filelisttoarray
dexter23 Posted January 24, 2008 Author Posted January 24, 2008 (edited) Again I used this script #Include <FileListToArray.au3> #Include <Array.au3> $path = @ScriptDir $FileList = _FileListToArray($path, "*.txt",1,1) _arraydisplay($FileList) For $i = 1 To $FileList[0] FileDelete($path & "\" & $FileList[$i]) ConsoleWrite($path & "\" & $FileList[$i]&@LF) Next and randallc's attachment files, but don't works. Edited January 24, 2008 by dexter23
weaponx Posted January 24, 2008 Posted January 24, 2008 randallc's function name isn't _FileListToArray...its _FileListToArray3
weaponx Posted January 24, 2008 Posted January 24, 2008 I don't know what to tell you man. His code is long and confusing and his function names always change. The examples aren't even very clear.Visit the link I posted above for some alternatives.http://www.autoitscript.com/forum/index.ph...filelisttoarray
dexter23 Posted January 24, 2008 Author Posted January 24, 2008 Using this ; filedel.au3 #Include <FileListToArray.au3> #Include <Array.au3> $path = @ScriptDir $FileList = _FileListToArray($path, "*.txt",1,1) _arraydisplay($FileList) For $i = 1 To $FileList[0] FileDelete($path & "\" & $FileList[$i]) ConsoleWrite($path & "\" & $FileList[$i]&@LF) Next the files is founded and listed, but aren't deleted.
randallc Posted January 24, 2008 Posted January 24, 2008 with those 2 files provided, but nothing.Hi, Sorry; you don't need the path. $FileList = _FileListToArray($path, "*.txt",1,1) FileDelete($FileList[$i])oÝ÷ ÚÚºÚ"µÍÌÍÑ[SÝHÑ[SÝÐ^J ÌÍÜ] ][ÝÊ ][ÝËKK B[Q[]J ÌÍÜ] [È ][ÝÉÌLÉ][ÝÈ [ÉÌÍÑ[SÝÉÌÍÚWJ Just as well, though; you don't want to delete your scriptdirectory files?>... Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
dexter23 Posted January 24, 2008 Author Posted January 24, 2008 Just as well, though; you don't want to delete your scriptdirectory files?>...Now it works. Thx Randall.
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