找回密码
 加入
搜索
查看: 4486|回复: 11

[AU3基础] 用au3 取得檔案最近存取日期

  [复制链接]
发表于 2012-8-4 20:28:11 | 显示全部楼层 |阅读模式
hi,各位大大
在下是初學者有一問題想請教如何用au3去 獲取檔案總管內如c:\1. txt檔的最近存取日期與其它 0.txt及2.txt檔相比較,非常感激,謝謝!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-8-4 20:34:19 | 显示全部楼层
FileGetTime ( "文件名" [, 选项 [, 格式]] )

自行查看帮助。。
发表于 2012-8-4 20:37:43 | 显示全部楼层
这个在帮助  有现成的哦
$t =  FileGetTime(@Windowsdir & "\Notepad.exe", 1)

If Not @error Then
    $yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2]
    MsgBox(0, "notepad.exe 创建日期:", $yyyymd)
EndIf
 楼主| 发表于 2012-8-4 21:06:00 | 显示全部楼层
謝謝大大回覆:
可能寫不清楚,要的是從以上0.txt,1.txt,2.txt因存取時間會變動要得到最近時間檔案後取出1.txt的1該如何寫
发表于 2012-8-4 21:48:38 | 显示全部楼层

#include <File.au3>
$txtfile = _FileListToArray("C:\", "*.txt", 1)
If @error Then Exit
If IsArray($txtfile) Then
        $lastmodifytime = $txtfile
        For $i = 1 To $txtfile[0]
                $lastmodifytime[$i] = FileGetTime("C:\" & $txtfile[$i], 0, 1)
        Next
        $last = $lastmodifytime[1]
        $last_index = 1
        For $i = 2 To $txtfile[0]
                If StringCompare($last, $lastmodifytime[$i])<0 Then
                        $last = $lastmodifytime[$i]
                        $last_index = $i
                EndIf
        Next
        MsgBox(0, "文件(带扩展名)", $txtfile[$last_index])
        ;;;;;        $szDrive = ""
        ;;;;;        $szDir = ""
        ;;;;;        $szFName = ""
        ;;;;;        $szExt = ""
        ;;;;;        _PathSplit("C:\" & $txtfile[$last_index], $szDrive, $szDir, $szFName, $szExt)
        ;;;;;        MsgBox(0, "文件(不带扩展名)", $szFName)
EndIf
发表于 2012-8-4 22:00:45 | 显示全部楼层
回复 4# cks1203
#include <Array.au3>
Local $TimeOfNewestFile, $FileTime[3]
$FileTime[0] = Number(FileGetTime(@ScriptDir&"\0.txt",0,1))  ;把0.txt的文件修改时间转换为数字
$FileTime[1] = Number(FileGetTime(@ScriptDir&"\1.txt",0,1))
$FileTime[2] = Number(FileGetTime(@ScriptDir&"\2.txt",0,1))
MsgBox(0,"最新的文件名是",_ArrayMaxIndex($FileTime,1))
 楼主| 发表于 2012-8-5 23:20:11 | 显示全部楼层
veket_linux  大大:
真是厲害把問題這樣就解決了,感謝您
 楼主| 发表于 2012-8-5 23:26:01 | 显示全部楼层
xms77 大大:
我測試了您的解答是可以跑的出來如果可以給未知數的.txt那就更好了
发表于 2012-8-6 09:07:01 | 显示全部楼层
脚印留下。。。。
发表于 2012-8-9 09:28:15 | 显示全部楼层
膜拜神人,所有的问题在大大的眼里都不是问题!!
发表于 2012-8-9 15:34:52 | 显示全部楼层
。。。。。。。。。。
发表于 2012-8-10 17:56:40 | 显示全部楼层
veket_linux太厲害了,剛好解答我檔案搜尋的問題
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-20 11:58 , Processed in 0.084409 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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