You are not logged in.
I have some files named as:
1621184624 - xxxx.jpg
...
I just want to replace the time stamp to date time, like:
2021-05-16 - xxxx.jpg
I have already searched the 'timestamp', but not seeing anything related to what I'm trying to do.
In addition, I am not familiar with the 'Pascal Script', so would like to ask help from here,
thanks.
Offline
Hi,
Please try following Pascal Script rule if works for your files:
var
DateTime: TDateTime;
Parts: TStringsArray;
begin
Parts := SubMatchesRegEx(WideExtractBaseName(FileName), '(162\d+)(.+)', false);
If (Length(Parts) <=0) then exit;
DateTime := UnixToDateTime(StrToInt64(Parts[0]));
FileName := FormatDateTime('yyyy-mm-dd', DateTime) + Parts[1] + WideExtractFileExt(FileName);
end.
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline
Hi,
Please try following Pascal Script rule if works for your files:
var DateTime: TDateTime; Parts: TStringsArray; begin Parts := SubMatchesRegEx(WideExtractBaseName(FileName), '(162\d+)(.+)', false); If (Length(Parts) <=0) then exit; DateTime := UnixToDateTime(StrToInt64(Parts[0])); FileName := FormatDateTime('yyyy-mm-dd', DateTime) + Parts[1] + WideExtractFileExt(FileName); end.
Wow, awesome,it works!Very appreciate!
seems that I need to learn some programming, LOL!
And I have a small question:
If the beginning is not 162, but other numbers, how to deal with it?
As shown in the figure, i have many files of different years.
Offline
You're welcome. Replace '(162\d+)(.+)' part in line 6 with '(\d+)(.+)' i.e. just remove 162 and it should work
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline
You're welcome. Replace '(162\d+)(.+)' part in line 6 with '(\d+)(.+)' i.e. just remove 162 and it should work
Thanks buddy, big help!
Offline
I'm not sure if there is Unix timestamp format in Reformat Date rule. If not, maybe it can be added
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline
I'm not sure if there is Unix timestamp format in Reformat Date rule. If not, maybe it can be added
I don't know much about timestamp, but the date after conversion is right,
Last edited by Bingman (2021-06-21 11:52)
Offline