Paste FileName and TimeModified each one in separate column excel Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Paste FileName and TimeModified each one in separate column excel

19 Jan 2021, 11:49

hello ,

i have this code

Code: Select all

SetWorkingDir, %A_ScriptDir%
FileList := "File Name,TimeLastModified"
Loop, %A_ScriptDir%\*.*
{
  FormatTime, last_time_modified, %A_LoopFileTimeModified%, MM/dd/yyyy hh:mm:ss
  FileList .= "`n" . A_LoopFileName . "," . last_time_modified
}
FileAppend,%FileList%,FileList.csv
Run, excel.exe "FileList.csv"
this put File Name And TimeModified in one column (A) ,how i can send File Name to column "A" TimeLastModified to column "B"

for more details :

I wrote also this code this work Well, but in this way should i click at cell "A1" and click at F1 to paste file name and like this for TimeLastModified should i click at "B1" cell then click at F2 and so on, i think there are Better way to do that .

Code: Select all

SetWorkingDir, %A_ScriptDir%
FileList := "Base name,TimeLastModified"
Loop, %A_ScriptDir%\*.*
{
  FormatTime, last_time_modified, %A_LoopFileTimeModified%, MM/dd/yyyy hh:mm:ss
  FileName .= "`n" . A_LoopFileName
  FileDate .= "`n" . last_time_modified
}
f1:: send , % FileName
f2:: send , % FileDate

this is My last attempts:

Code: Select all

setWorkingDir, %A_ScriptDir%
FileList := "Base name,TimeLastModified"
Loop, %A_ScriptDir%\*.*
{
  FormatTime, last_time_modified, %A_LoopFileTimeModified%, MM/dd/yyyy hh:mm:ss
  FileName .= "`n" . A_LoopFileName
    FileDate .= "`n" . last_time_modified
}
Xl := ComObjCreate("Excel.Application")
Xl.Visible := True ;by default excel sheets are invisible
Xl.Workbooks.Add ;add a new workbook
Xl.Range("A1").Value := FileName ;Send clipboard to selected cell
Xl.Range("B1").Value := FileDate ;Send clipboard to selected cell
but trouble of that code is it combined all of files name in one cell "A1" and time modified in "B1".
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Paste FileName and TimeModified each one in separate column excel  Topic is solved

20 Jan 2021, 01:23

Hope it will help ya...

Code: Select all

Xl := ComObjCreate("Excel.Application")
Xl.Visible := True ;by default excel sheets are invisible
wb := Xl.Workbooks.Add ;add a new workbook and also return with separate object variable so we can specifically handle that one 
sheet := wb.sheets(1) ; return with sheet
FN := sheet.range("A1") ; return with cell A1
DT := sheet.range("B1")
FN.Value := "FileNames" 
DT.Value := "Modiftdate"
setWorkingDir, %A_ScriptDir%
FileList := "Base name,TimeLastModified"
Loop, %A_ScriptDir%\*.*
{
	FormatTime, last_time_modified, %A_LoopFileTimeModified%, MM/dd/yyyy hh:mm:ss
	FN.offset(a_index,0).value := A_LoopFileName ; with offset you can got to any cell relatively 
	DT.offset(a_index,0).value := last_time_modified
}
sheet.range("A:B").columns.AutoFit ; auto fit columns AB
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Re: Paste FileName and TimeModified each one in separate column excel

20 Jan 2021, 01:42

you're a genius that's what i was looking for :) ,
thanks you @Xeo786 , you make my day :dance: ...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 390 guests