Get File DateTime
Get File DateTime
Is there a way of getting the DateTime of a file? I have to download a file on a remote system that I have no control over and is updated every 30 minutes (the name doesn't change, just new time stamp). When I download the file I want to rename it to include the DateTime (i.e. FILE.CSV would become FILE201412180703.CSV).
Re: Get File DateTime
Don't need this now. Just renaming from FILE.CSV to FILE{Year}{MonthNo}{Day}{Hours}{Minutes}.CSV. The Timestamp on the file is preserved.
Re: Get File DateTime
Look at variables FileTime (Files & Folders group) and DateTimeToFormat (Date & Time group)
See format settings here (at the bottom of the page)
Format options for format variables:
d - Displays the day as a number without a leading zero (1-31).
dd - Displays the day as a number with a leading zero (01-31).
mm - Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
yy - Displays the year as a two-digit number (00-99).
yyyy - Displays the year as a four-digit number (0000-9999).
h - Displays the hour without a leading zero (0-23).
hh - Displays the hour with a leading zero (00-23).
n - Displays the minute without a leading zero (0-59).
nn - Displays the minute with a leading zero (00-59).
s - Displays the second without a leading zero (0-59).
ss - Displays the second with a leading zero (00-59).
am/pm - Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
a/p - Uses the 12-hour clock for the preceding h or hh specifier, and displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
Also see the example below.
See format settings here (at the bottom of the page)
Format options for format variables:
d - Displays the day as a number without a leading zero (1-31).
dd - Displays the day as a number with a leading zero (01-31).
mm - Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
yy - Displays the year as a two-digit number (00-99).
yyyy - Displays the year as a four-digit number (0000-9999).
h - Displays the hour without a leading zero (0-23).
hh - Displays the hour with a leading zero (00-23).
n - Displays the minute without a leading zero (0-59).
nn - Displays the minute with a leading zero (00-59).
s - Displays the second without a leading zero (0-59).
ss - Displays the second with a leading zero (00-59).
am/pm - Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
a/p - Uses the 12-hour clock for the preceding h or hh specifier, and displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
Also see the example below.
Code: Select all
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1416408852
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task119"
Hide=INTEGER|0
ID=INTEGER|468440609
LogOnAsUser=INTEGER|1
Name=STRING|"Show ""File time""..."
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FILENAME"" with value ""C:\Temp\108736_2.jpeg"""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FILENAME"
varvalue=STRING|"C:\Temp\108736_2.jpeg"
[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""File Name: {FileName} """
Params=FOLDER
[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"File Name: {FileName} "
msg2=STRING|"File time"
msg3=STRING|"{FileTime({FileName})}"
msg5=STRING|"transformed file time:"
msg6=STRING|"{DateTimeToFormat({FileTime({FileName})},yyyy-mm-dd-hh-nn-ss)}"
msgcount=STRING|"7"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov