Change File Date or Time
Posted: Fri Jul 12, 2024 1:03 pm
Does RoboTask have any way to change a file's date and or time (Modified and Created)? Thanks in advance
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"
Code: Select all
(Get-Item "D:\systemp\test.txt").CreationTime = '2024-11-13 06:00:00'
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;}
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
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"