AutoHotKey:如何将当前工作目录的“修改日期”放入剪贴板?

AutoHotKey:如何将当前工作目录的“修改日期”放入剪贴板?

我有一个脚本,可以将我们服务器上媒体目录中的基本文件夹名称和文件数量记录到电子表格中。但是,我还需要添加一行代码来检索当前工作目录的“修改日期”并将其放入剪贴板。有一段代码可以获取工作目录的文件数量并将其放入剪贴板,我想在这些数据进入电子表格后执行修改日期检索。

在计算文件数之前,当前工作目录地址已经在剪贴板中,因此在将文件计数值粘贴到电子表格中后,我可以返回并再次将目录地址放入剪贴板(以检索其修改日期)。

是否有人知道我需要输入什么代码才能获取剪贴板中目录地址的修改日期,然后将修改日期数据直接复制到剪贴板中?

F1::

Spreadsheet:

{

Send, {F2}
Sleep, 200
Send, {Ctrl Down}
Sleep, 50
Send, c
sleep, 50
Send, {Ctrl Up}
Sleep, 200
Mouseclick, Left, 522,1009
Sleep, 200
Send, {Ctrl Down}
Sleep, 50
Send, v
sleep, 50
Send, {Ctrl Up}
Sleep, 100
Send, {Right}
Sleep, 50
Send, {Right}
Sleep, 50
Send, {Right}
Sleep, 200
Mouseclick, Left, 590,1013
Sleep, 200
Send, {Enter}
Sleep, 100
Send, {Alt Down}
Sleep, 100
Send, D
Sleep, 100
Send, {Alt Up}
Sleep, 100
Send, {Ctrl Down}
Sleep, 50
Send, c
sleep, 50
Send, {Ctrl Up}

; Calculate the number of files in a folder and its subfolders:
SetBatchLines, -1  ; Make the operation run at maximum speed.
FileNum = 0
; FileSelectFolder, WhichFolder  ; Ask the user to pick a folder.
WhichFolder := Clipboard  ;  assumes full path to folder is in clipboard
Loop, Files, %WhichFolder%\*.*, R
{
    if A_LoopFileAttrib contains H,R,S  ; Skip any file that is either Hidden, Read-only, or System
        continue  ; Skip this file and move on to the next one
    FileNum += 1
}
Clipboard := FileNum
ClipWait  ; Wait for the clipboard to contain text.

Sleep, 200
Mouseclick, Left, 522,1009
Sleep, 200
Send, {Ctrl Down}
Sleep, 50
Send, v
sleep, 50
Send, {Ctrl Up}
Sleep, 100
Send, {Down}
Sleep, 50
Send, {Left}
Sleep, 50
Send, {Left}
Sleep, 50
Send, {Left}
Sleep, 200
Mouseclick, Left, 590,1013
Sleep, 250
Send, {Tab}
Sleep, 400
Send, {Right}
Sleep, 100
Send, {Right}
Sleep, 100
Send, {Right}
Sleep, 100
Send, {Right}
Sleep, 100
Send, {Right}
Sleep, 100
Send, {Enter}
Sleep, 100
Send, {Down}
Goto, Spreadsheet


Esc::ExitApp

非常感谢您的帮助!

答案1

您需要的 AHK 代码是:

folder = %clipboard%
FileGetTime, modtime , %folder%, A
FormatTime, mytime , %modtime%, yyyymmddhh24
clipboard = %mytime%

这将以以下格式复制 YYYYMMDDHH24,您可能需要将其输入到您喜欢的格式中。

相关内容