找回密码
 加入
搜索
查看: 1487|回复: 5

获取文件名的问题

[复制链接]
发表于 2009-7-2 17:55:03 | 显示全部楼层 |阅读模式
本帖最后由 tcbyjason 于 2009-7-3 21:30 编辑
Search("D:", "")
Func Search($current, $ext)
        Local $search = FileFindFirstFile($current & "\*.*")
        While 1
                Dim $file = FileFindNextFile($search)
                If @error Or StringLen($file) < 1 Then ExitLoop
                If Not StringInStr(FileGetAttrib($current & "" & $file), "D") And ($file <> "."  Or $file <> "..") Then
                        If StringRight($current & "" & $file, StringLen($ext)) = $ext Then
                                MsgBox(0,0,$current & "" & $file)
                        EndIf
                EndIf
                If StringInStr(FileGetAttrib($current & "" & $file), "D") And ($file <> "."  Or $file <> "..") Then
                        Search($current & "" & $file, $ext)
                
                EndIf
        WEnd
        Return
EndFunc   ;==>Search
 楼主| 发表于 2009-7-2 17:56:16 | 显示全部楼层
本帖最后由 tcbyjason 于 2009-7-2 17:57 编辑

上面那代码是在论坛找到的,我想知道如果要把结果保存为文件如何搞?
例如我要把结果保存成一个文本文档,扫描出来的文件名要带有完整路径。
还有,如何修改才能让它自己扫描整个硬盘的文件?
发表于 2009-7-2 18:32:47 | 显示全部楼层
[au3]$txt = FileOpen("txt.txt", 1)
$var = DriveGetDrive("FIXED")
If Not @error Then
        For $i = 1 To $var[0]
                Search($var[$i] & "\", "")
        Next
EndIf


Func Search($current, $ext)
        Local $search = FileFindFirstFile($current & "\*.*")
        While 1
                Dim $file = FileFindNextFile($search)
                If @error Or StringLen($file) < 1 Then ExitLoop
                If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."  Or $file <> "..") Then
                        If StringRight($current & "\" & $file, StringLen($ext)) = $ext Then
;~                                 MsgBox(0, 0, $current & "\" & $file)
                                FileWriteLine($txt, $current & "\" & $file)
                        EndIf
                EndIf
                If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "."  Or $file <> "..") Then
                        Search($current & "\" & $file, $ext)
                EndIf
        WEnd
        Return
EndFunc   ;==>Search[/au3]
 楼主| 发表于 2009-7-2 21:35:21 | 显示全部楼层
本帖最后由 tcbyjason 于 2009-7-2 22:38 编辑

我想程序扫描除了C盘之外的盘应该怎么弄?(知道怎么修改代码,但是不会弄配置文件)
还有个问题就是,用文本文档保存的话,数据太多就难打开了。(希望能在配置文件指定要保存的文件类型)
最好能弄个进度条,显示扫到什么地方。
发表于 2009-7-4 13:30:58 | 显示全部楼层
那只是个函数而已,进度条可以自己加
发表于 2009-7-13 15:59:16 | 显示全部楼层
真是不错的东西,收了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-5 06:11 , Processed in 0.071571 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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