Change File Date or Time
Change File Date or Time
Does RoboTask have any way to change a file's date and or time (Modified and Created)? Thanks in advance
Windows 11 Pro, RoboTask v10.6
Re: Change File Date or Time
Look at the File Date and Time action. It can set specified date-time of file or folder (file modified date-time)
Oleg Yershov
Re: Change File Date or Time
I need a method to change the CREATED date/time. The only thing I could find was to change the MODIFIED date/time.
Below is my script
Below is my script
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1332952927
Comment=STRINGLIST
ContinueOnError=INTEGER|2
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task22"
Hide=INTEGER|0
ID=INTEGER|-1403238825
LogOnAsUser=INTEGER|1
Name=STRING|"Fix Recall File Dates"
OnErrorTaskID=INTEGER|1879502808
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|1
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action16=FOLDER
Action17=FOLDER
Action18=FOLDER
Action19=FOLDER
Action2=FOLDER
Action20=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER
[Actions\Action1]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action1\Params]
message=STRING|"====== [Start Task:] Fix Recall File Dates"
type=STRING|"3"
[Actions\Action10]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TempCreatedDateTime"" with value ""{FileCreateTime({CurrentFileName})}"""
Params=FOLDER
[Actions\Action10\Params]
_rt_variables_produced=STRING|"TempCreatedDateTime"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"TempCreatedDateTime"
varvalue=STRING|"{FileCreateTime({CurrentFileName})}"
[Actions\Action11]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action11\Params]
message=STRING|"Temp Created Date Time [Before STR Update]: {TempCreatedDateTime}"
type=STRING|"3"
[Actions\Action12]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER
[Actions\Action12\Params]
_rt_variables_produced=STRING|"TempCreatedDateTime"
case=STRING|"0"
mode=STRING|"2"
replacement=STRING|":00"
source=STRING|"{TempCreatedDateTime}"
substring=STRING|":01"
variable=STRING|"TempCreatedDateTime"
[Actions\Action13]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER
[Actions\Action13\Params]
_rt_variables_produced=STRING|"TempCreatedDateTime"
case=STRING|"0"
mode=STRING|"2"
replacement=STRING|":00"
source=STRING|"{TempCreatedDateTime}"
substring=STRING|":02"
variable=STRING|"TempCreatedDateTime"
[Actions\Action14]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action14\Params]
message=STRING|"Temp Created Date Time [After STR Update]: {TempCreatedDateTime}"
type=STRING|"3"
[Actions\Action15]
ActionID=STRING|"A_FILE_DATETIME"
Enabled=INTEGER|-1
Name=STRING|"File Date and Time"
Params=FOLDER
[Actions\Action15\Params]
datetime=STRING|"{TempCreatedDateTime}"
files=STRING|"{CurrentFileName}"
processfiles=STRING|"1"
processfolders=STRING|"0"
withsubfolders=STRING|"0"
[Actions\Action16]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action16\Params]
message=STRING|"Updated Current File Created Date Time: {FileCreateTime({CurrentFileName})}"
type=STRING|"3"
[Actions\Action17]
ActionID=STRING|"A_FILE_ATTRIBUTES"
Enabled=INTEGER|0
Name=STRING|"Change attributes of file ""{FileName}"""
Params=FOLDER
[Actions\Action17\Params]
archive=STRING|"0"
filename=STRING|"{FileName}"
hidden=STRING|"0"
readonly=STRING|"0"
system=STRING|"0"
[Actions\Action18]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action18\Params]
message=STRING|" "
type=STRING|"3"
[Actions\Action19]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""CurrentFileName"" with value """""
Params=FOLDER
[Actions\Action2\Params]
_rt_variables_produced=STRING|"CurrentFileName"
expand=STRING|"0"
linecount=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CurrentFileName"
[Actions\Action20]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action20\Params]
message=STRING|"====== [End Task:] Fix Recall File Dates"
type=STRING|"3"
[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""CurrentFileCreatedDateTime"" with value """""
Params=FOLDER
[Actions\Action3\Params]
_rt_variables_produced=STRING|"CurrentFileCreatedDateTime"
expand=STRING|"0"
linecount=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CurrentFileCreatedDateTime"
[Actions\Action4]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""CurrentFileModifiedDateTime"" with value """""
Params=FOLDER
[Actions\Action4\Params]
_rt_variables_produced=STRING|"CurrentFileModifiedDateTime"
expand=STRING|"0"
linecount=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CurrentFileModifiedDateTime"
[Actions\Action5]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TempCreatedDateTime"" with value """""
Params=FOLDER
[Actions\Action5\Params]
_rt_variables_produced=STRING|"TempCreatedDateTime"
expand=STRING|"0"
linecount=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TempCreatedDateTime"
[Actions\Action6]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TempModifiedDateTime"" with value """""
Params=FOLDER
[Actions\Action6\Params]
_rt_variables_produced=STRING|"TempModifiedDateTime"
expand=STRING|"0"
linecount=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TempModifiedDateTime"
[Actions\Action7]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER
[Actions\Action7\Params]
_rt_variables_produced=STRING|"CurrentFileName"
createmode=STRING|"7"
createormodified=STRING|"1"
date1=STRING|"20240710"
date2=STRING|"20240710"
destvar=STRING|"CurrentFileName"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"11"
DuringMonths=STRING|"1"
file0=STRING|"C:\Users\redwa\Pictures\Recall\*.jpg"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"1"
sortby=STRING|"1"
sortorder=STRING|"1"
subdirs=STRING|"0"
timesize=STRING|"0"
timevar=STRING|"CurrentFileModifiedDateTime"
WithoutPath=STRING|"0"
[Actions\Action8]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action8\Params]
message=STRING|"Current File Name: {CurrentFileName}"
type=STRING|"3"
[Actions\Action9]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action9\Params]
message=STRING|"Current File Created Date Time: {FileCreateTime({CurrentFileName})}"
type=STRING|"3"Windows 11 Pro, RoboTask v10.6
Re: Change File Date or Time
There is no native function of RoboTask. I wrote this into our ToDo
But you can use powershell script. For example:
It can get universal format of date-time: YYYY-MM-DD hh:nn:ss
You can use also american date-time format: MM/DD/YYYY hh:nn:ss
Read here information about all properties of file object
But you can use powershell script. For example:
Code: Select all
(Get-Item "D:\systemp\test.txt").CreationTime = '2024-11-13 06:00:00'You can use also american date-time format: MM/DD/YYYY hh:nn:ss
Code: Select all
(Get-Item "D:\systemp\test.txt").CreationTime = '11/13/2024 06:00:00'Code: Select all
TypeName: System.IO.FileInfo
Name MemberType Definition
---- ---------- ----------
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property System.DateTime CreationTime {get;set;}
CreationTimeUtc Property System.DateTime CreationTimeUtc {get;set;}
Directory Property System.IO.DirectoryInfo Directory {get;}
DirectoryName Property System.String DirectoryName {get;}
Exists Property System.Boolean Exists {get;}
Extension Property System.String Extension {get;}
FullName Property System.String FullName {get;}
IsReadOnly Property System.Boolean IsReadOnly {get;set;}
LastAccessTime Property System.DateTime LastAccessTime {get;set;}
LastAccessTimeUtc Property System.DateTime LastAccessTimeUtc {get;set;}
LastWriteTime Property System.DateTime LastWriteTime {get;set;}
LastWriteTimeUtc Property System.DateTime LastWriteTimeUtc {get;set;}
Length Property System.Int64 Length {get;}
Name Property System.String Name {get;}Oleg Yershov
Re: Change File Date or Time
For the script I'm working on I only need to set the SECONDS to 00. Thanks for adding it to your ToDo list
This is the output when I tried the Powershell thing you suggested
7/15/2024 4:42:44 PM: Temp Created Date Time [Before STR Update]: 7/15/2024 4:35:01 PM
7/15/2024 4:42:44 PM: Temp Created Date Time [After STR Update]: 7/15/2024 4:35:00 PM
7/15/2024 4:42:44 PM: [STDOUT] Set-Item : Provider operation stopped because the provider does not support this operation.
7/15/2024 4:42:44 PM: [STDOUT] At C:\Users\redwa\AppData\Local\Temp\qw3n7NHbwTVrxLpMMm5V76PhLPHD7hsy.ps1:1 char:2
7/15/2024 4:42:44 PM: [STDOUT] + (Set-Item "{FileName}").CreationTime = '{TempCreatedDateTime}'
7/15/2024 4:42:44 PM: [STDOUT] + ~~~~~~~~~~~~~~~~~~~~~
7/15/2024 4:42:44 PM: [STDOUT] + CategoryInfo : NotImplemented: (:) [Set-Item], PSNotSupportedException
7/15/2024 4:42:44 PM: [STDOUT] + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.SetItemCommand
7/15/2024 4:42:44 PM: [STDOUT]
This is the output when I tried the Powershell thing you suggested
7/15/2024 4:42:44 PM: Temp Created Date Time [Before STR Update]: 7/15/2024 4:35:01 PM
7/15/2024 4:42:44 PM: Temp Created Date Time [After STR Update]: 7/15/2024 4:35:00 PM
7/15/2024 4:42:44 PM: [STDOUT] Set-Item : Provider operation stopped because the provider does not support this operation.
7/15/2024 4:42:44 PM: [STDOUT] At C:\Users\redwa\AppData\Local\Temp\qw3n7NHbwTVrxLpMMm5V76PhLPHD7hsy.ps1:1 char:2
7/15/2024 4:42:44 PM: [STDOUT] + (Set-Item "{FileName}").CreationTime = '{TempCreatedDateTime}'
7/15/2024 4:42:44 PM: [STDOUT] + ~~~~~~~~~~~~~~~~~~~~~
7/15/2024 4:42:44 PM: [STDOUT] + CategoryInfo : NotImplemented: (:) [Set-Item], PSNotSupportedException
7/15/2024 4:42:44 PM: [STDOUT] + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.SetItemCommand
7/15/2024 4:42:44 PM: [STDOUT]
Windows 11 Pro, RoboTask v10.6
Re: Change File Date or Time
Maybe you forgot to switch on this option?
If you are using RoboTask variables in script body you should expand variables before running.
Oleg Yershov
Re: Change File Date or Time
I running Windows 11 Pro
Here is my output below
------------------------------
I 7/16/2024 8:42:46 AM: ****** Starting task: PowerShell Script... ******************
I 7/16/2024 8:42:46 AM: Executing "1.Log Message"
7/16/2024 8:42:46 AM: Powershell : (Set-Item "C:\Users\redwa\Pictures\Recall\Recall 2024-07-15 16-30.jpg").CreationTime='11/13/2024 16:30:00'
I 7/16/2024 8:42:46 AM: Executing "2.PowerShell Script"
7/16/2024 8:42:46 AM: [STDOUT] Set-Item : Provider operation stopped because the provider does not support this operation.
7/16/2024 8:42:46 AM: [STDOUT] At C:\Users\redwa\AppData\Local\Temp\1SvHowfDknNpCrNCCovLVoscZsFGaOv6.ps1:1 char:2
7/16/2024 8:42:46 AM: [STDOUT] + (Set-Item "C:\Users\redwa\Pictures\Recall\Recall 2024-07-15 16-30.jpg ...
7/16/2024 8:42:46 AM: [STDOUT] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7/16/2024 8:42:46 AM: [STDOUT] + CategoryInfo : NotImplemented: (:) [Set-Item], PSNotSupportedException
7/16/2024 8:42:46 AM: [STDOUT] + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.SetItemCommand
7/16/2024 8:42:46 AM: [STDOUT]
I 7/16/2024 8:42:46 AM: Task executed successfully
Here is my output below
------------------------------
I 7/16/2024 8:42:46 AM: ****** Starting task: PowerShell Script... ******************
I 7/16/2024 8:42:46 AM: Executing "1.Log Message"
7/16/2024 8:42:46 AM: Powershell : (Set-Item "C:\Users\redwa\Pictures\Recall\Recall 2024-07-15 16-30.jpg").CreationTime='11/13/2024 16:30:00'
I 7/16/2024 8:42:46 AM: Executing "2.PowerShell Script"
7/16/2024 8:42:46 AM: [STDOUT] Set-Item : Provider operation stopped because the provider does not support this operation.
7/16/2024 8:42:46 AM: [STDOUT] At C:\Users\redwa\AppData\Local\Temp\1SvHowfDknNpCrNCCovLVoscZsFGaOv6.ps1:1 char:2
7/16/2024 8:42:46 AM: [STDOUT] + (Set-Item "C:\Users\redwa\Pictures\Recall\Recall 2024-07-15 16-30.jpg ...
7/16/2024 8:42:46 AM: [STDOUT] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7/16/2024 8:42:46 AM: [STDOUT] + CategoryInfo : NotImplemented: (:) [Set-Item], PSNotSupportedException
7/16/2024 8:42:46 AM: [STDOUT] + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.SetItemCommand
7/16/2024 8:42:46 AM: [STDOUT]
I 7/16/2024 8:42:46 AM: Task executed successfully
Windows 11 Pro, RoboTask v10.6
Re: Change File Date or Time
I ran this for your information
7/16/2024 8:51:48 AM: ****** Starting task: PowerShell Script... ******************
7/16/2024 8:51:48 AM: Executing "1.Log Message"
7/16/2024 8:51:48 AM: Executing "2.PowerShell Script"
7/16/2024 8:51:48 AM: [STDOUT]
7/16/2024 8:51:48 AM: [STDOUT] Name Value
7/16/2024 8:51:48 AM: [STDOUT] ---- -----
7/16/2024 8:51:48 AM: [STDOUT] PSVersion 5.1.22621.3880
7/16/2024 8:51:48 AM: [STDOUT] PSEdition Desktop
7/16/2024 8:51:48 AM: [STDOUT] PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
7/16/2024 8:51:48 AM: [STDOUT] BuildVersion 10.0.22621.3880
7/16/2024 8:51:48 AM: [STDOUT] CLRVersion 4.0.30319.42000
7/16/2024 8:51:48 AM: [STDOUT] WSManStackVersion 3.0
7/16/2024 8:51:48 AM: [STDOUT] PSRemotingProtocolVersion 2.3
7/16/2024 8:51:48 AM: [STDOUT] SerializationVersion 1.1.0.1
7/16/2024 8:51:48 AM: Task executed successfully
7/16/2024 8:51:48 AM: ****** Starting task: PowerShell Script... ******************
7/16/2024 8:51:48 AM: Executing "1.Log Message"
7/16/2024 8:51:48 AM: Executing "2.PowerShell Script"
7/16/2024 8:51:48 AM: [STDOUT]
7/16/2024 8:51:48 AM: [STDOUT] Name Value
7/16/2024 8:51:48 AM: [STDOUT] ---- -----
7/16/2024 8:51:48 AM: [STDOUT] PSVersion 5.1.22621.3880
7/16/2024 8:51:48 AM: [STDOUT] PSEdition Desktop
7/16/2024 8:51:48 AM: [STDOUT] PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
7/16/2024 8:51:48 AM: [STDOUT] BuildVersion 10.0.22621.3880
7/16/2024 8:51:48 AM: [STDOUT] CLRVersion 4.0.30319.42000
7/16/2024 8:51:48 AM: [STDOUT] WSManStackVersion 3.0
7/16/2024 8:51:48 AM: [STDOUT] PSRemotingProtocolVersion 2.3
7/16/2024 8:51:48 AM: [STDOUT] SerializationVersion 1.1.0.1
7/16/2024 8:51:48 AM: Task executed successfully
Windows 11 Pro, RoboTask v10.6
Re: Change File Date or Time
Why Set-item ???I 7/16/2024 8:42:46 AM: Executing "2.PowerShell Script"
7/16/2024 8:42:46 AM: [STDOUT] Set-Item : Provider operation stopped because the provider does not support this operation.
7/16/2024 8:42:46 AM: [STDOUT] At C:\Users\redwa\AppData\Local\Temp\1SvHowfDknNpCrNCCovLVoscZsFGaOv6.ps1:1 char:2
I wrote
Also look at my task below. It works(Get-Item "D:\systemp\test.txt").CreationTime = '11/13/2024 06:00:00'
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task45"
Hide=INTEGER|0
ID=INTEGER|-1716440280
LogOnAsUser=INTEGER|1
Name=STRING|"change createion time of the file"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""filename"" with value ""D:\systemp\test.txt"""
Params=FOLDER
[Actions\Action1\Params]
_rt_variables_produced=STRING|"filename"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"filename"
varvalue=STRING|"D:\systemp\test.txt"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""creationDT"" with value ""2024-07-16 10:00:00"""
Params=FOLDER
[Actions\Action2\Params]
_rt_variables_produced=STRING|"creationDT"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"creationDT"
varvalue=STRING|"2024-07-16 10:00:00"
[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""writeDT"" with value ""2024-07-16 11:00:00"""
Params=FOLDER
[Actions\Action3\Params]
_rt_variables_produced=STRING|"writeDT"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"writeDT"
varvalue=STRING|"2024-07-16 11:00:00"
[Actions\Action4]
ActionID=STRING|"A_SCRIPT_POWERSHELLSCRIPT"
Enabled=INTEGER|-1
Name=STRING|"PowerShell Script"
Params=FOLDER
[Actions\Action4\Params]
command_line_template=STRING|"""[InterpreterPath]"" -ExecutionPolicy RemoteSigned -File ""[ScriptPath]"""
expand=STRING|"1"
script_0=STRING|"(Get-Item ""{filename}"").CreationTime = '{creationDT}'"
script_1=STRING|"(Get-Item ""{filename}"").LastWriteTime = '{writeDT}'"
script_count=STRING|"2"
script_type=STRING|"0"
search_paths_count=STRING|"0"
use_embedded=STRING|"0"
Oleg Yershov