I have a script that logs basic folder name and file count from media directories on our server into a spreadsheet. However, I also need to add a line of code that retrieves the 'Date Modified' of the current working directory and put it into the clipboard. There's a section of code that takes the file count of the working directory and puts it into the clipboard and I'd like to execute the date modified retrieval after that data has gone into the spreadsheet.

The current working directory address is already in the clipboard prior to the file count calculation, so after file count value is pasted into the spreadsheet, I can go back and make the directory address go into the clipboard again (to retrieve date modified of it).

Does anyone know what code I need to put in order to get Date Modified of the directory address i have in the clipboard and then copy that Date Modified data into the clipboard straight after?

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

Many Thanks for any help in Advance!

up vote 2 down vote accepted

The AHK code you need is :

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

This will copy it in the format of YYYYMMDDHH24, which you will need perhaps to put in your preferred format.

  • Hi Harry, this looks like it's worked. Although the sample that has come through is as you've described '20180921005154'. Is there no way for AHK to reformat the date before it supplies it? I'm trying to get the 'format settings' of my spreadsheet column to translate the data into something better but i get ''######' for every setting. Manually reformatting it for each cell would defeat the purpose of the automation i've got going here. – Myles Sep 24 at 13:31
  • 1
    Which date-time format are you using? – harrymc Sep 24 at 13:36
  • 1
    AHK can do (almost) everything ... You might want to use its FormatTime command to massage the timestamp before sending it to the clipboard. – harrymc Sep 24 at 13:42
  • 1
    Have fun. Ask if you have a specific problem. – harrymc Sep 24 at 13:47
  • 1
    I modified the script to (hopefully) do what you want. – harrymc Sep 24 at 15:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.