找回密码
 加入
搜索
查看: 1830|回复: 4

[AU3基础] 【已解决】FileDelete()如何删除多个文件?

[复制链接]
发表于 2011-3-28 22:04:53 | 显示全部楼层 |阅读模式
本帖最后由 zjw767676 于 2011-3-28 23:35 编辑

FileDelete("路径")
FileDelete("d:\1.txt, 2.txt")这个不行
请教!!!!!!
发表于 2011-3-28 22:12:41 | 显示全部楼层
FileDelete("d:\1.txt")
FileDelete("d:\2.txt")
发表于 2011-3-28 22:35:06 | 显示全部楼层
Run(@ComSpec & " /c " & 'del   /q    D:\1\*.*', "", @SW_HIDE)
或者
_filedelete(@ScriptDir&"\backup",'*.jpg',0)
ShellExecute(@ScriptDir&"\backup")
 
Func _filedelete($path, $ext = '*.*', $flag = 0);_filedelete(路径,[[文件类型],0=不包括子目录,1=包括子目录(当包括子目录时只能用*.*)])
        Local $reulst,$abc
        If StringRight($path, 1) <> "" Then $path = $path & ""
        If $flag = 0 Then
                $reulst = FileDelete($path&$ext)
                Return $reulst
        ElseIf $flag = 1 And $ext = '*.*' Then
                $search = FileFindFirstFile($path&$ext)
                If $search = -1 Then
                        Return SetError(2)
                EndIf
                While 1
                        $file = FileFindNextFile($search)
                        If @error Then ExitLoop
                        $abc&=$path&$file&"|"
                        If FileGetAttrib($path&$file)='D' Then 
                                DirRemove($path&$file,1)
                        Else
                                FileDelete($path&$file)
                        EndIf
                WEnd
                FileClose($search)
        EndIf
EndFunc   ;==>_filedelete
 楼主| 发表于 2011-3-28 23:33:15 | 显示全部楼层
感谢楼上两位的热心解答!!!!!!!!!!!!
发表于 2011-3-29 10:18:09 | 显示全部楼层
FileDelete支持通配符,可以直接FileDelete("d:\*.txt")
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 10:24 , Processed in 0.071739 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表