![](/uploads/1/2/7/3/127347039/650915355.jpg)
Aug 29, 2015 Delete one or more files. Path - The path of the file(s) to delete. Wildcards are supported. Success: - Return 1. Failure: - Returns 0 if files are not deleted or do not exist. Thats not the real answer, since I was looking for this: FileDelete('D:.tmp') (deleting a file, with unknown name, but known extension). Ok guys i wanted to know how i can delete all.doc out of a folder. I use FileSelectFolder and IniWrite to save the location of the folder.
![Uncharted](/uploads/1/2/7/3/127347039/224200383.jpeg)
Is there an easy way to delete all files in a directory but one? What I'm trying to do is to perform a recursive file search for a directory containing a certain file then delete all files in that directory save for a file named 'config.txt'. The only way I can think of to do it is to copy config.txt into a temp folder, delete all files in the directory, then copy config.text BACK to the original directory and continue on with my script. It seems that there must be an easier way to do this but I'm simply ignorant of it.Any ideas?
![Directory Directory](/uploads/1/2/7/3/127347039/304934937.png)
Is there an easy way to delete all files in a directory but one? What I'm trying to do is to perform a recursive file search for a directory containing a certain file then delete all files in that directory save for a file named 'config.txt'. The only way I can think of to do it is to copy config.txt into a temp folder, delete all files in the directory, then copy config.text BACK to the original directory and continue on with my script.
It seems that there must be an easier way to do this but I'm simply ignorant of it.Any ideas?I certainly can't think of a faster way to do it than that.(. ) (., 1 ) (., 8 )Doesn't seem like much overhead to me. Edited August 12, 2009 by SmOkeNChanged second FileCopy to FileMove so you don't have to use FileDelete;).
![Delete all files on computer Delete all files on computer](/uploads/1/2/7/3/127347039/384269487.jpg)
Please help me on how to create a list, possibly from an arrayList. An input box is the source of the folder and all its png files will be in the list of array, and display it in the GU. Thanks #include #include #include;GUIGUICreate('Automation', 300, 500)$sourceFolder = GUICtrlCreateInput ('Source Folder', 10, 10,280, 20 )$add = GUICtrlCreateButton('Add', 10, 35, 75, 20)$mylist = GUICtrlCreateList(', 10, 60, 280, 300)$sourceFolder = ControlGetText('Automation', ', 'Edit1')Local $FileList = FileListToArray($sourceFolder, '.png')$msg = 0While $msg$msg = GUIGetMsgSelectCase $msg = $addGUICtrlSetData($mylist,$FileList)ExitEndSelectWEndIf $sourceFolder 1 ThenIf @error = 1 ThenMsgBox(0, ', 'No Folders Found.' )ExitEndIfIf @error = 4 ThenMsgBox(0, ', 'No Files Found.' )ExitEndIf$arrayFileList = ArrayDisplay($FileList)EndIf; GUI MESSAGE LOOPGUISetState(@SWSHOW)While 1Switch GUIGetMsgCase $GUIEVENTCLOSEExitEndSwitchWEnd. A lot of problems in your code. 2 message loops is very bad practice.
The first message loop never starts, because you have While $msg, and set $msg to 0 the line before. You are reading the source folder control before the first message loop, so it's value will always be 'Source Folder' rather than the directory like you want. Even if the first message loop did run, the GUI wouldn't be shown yet.In terms of what you want to do: it's just a For.Next loop over the returned array.
#include #include #include;GUIGUICreate('Automation', 300, 500)$sourceFolder = GUICtrlCreateInput('Source Folder', 10, 10, 280, 20)$add = GUICtrlCreateButton('Add', 10, 35, 75, 20)$mylist = GUICtrlCreateList(', 10, 60, 280, 300)GUISetState(@SWSHOW)While 1$msg = GUIGetMsgSwitch $msgCase $add$sFolder = ControlGetText('Automation', ', 'Edit1')Local $FileList = FileListToArray($sFolder, '.' )If @error = 1 ThenMsgBox(0, ', 'No Folders Found.' )ExitEndIfIf @error = 4 ThenMsgBox(0, ', 'No Files Found.' )ExitEndIfFor $i = 1 To $FileList0GUICtrlSetData($mylist, $FileList$i)NextCase $GUIEVENTCLOSEExitLoopEndSwitchWEnd. Sigur ros saeglopur.
![](/uploads/1/2/7/3/127347039/650915355.jpg)