You are not logged in.
Hello Stefan,
I noticed you added code to check for leading and trailing characters around the date in the file name. However, I'm unable to get it to do anything.
I created a bunch of dummy text files to give it a try, but always get a crtical error: Pascal Script Execute - [Line 27] Exception: Invalid argument to date encode
Examples of the dummy file names are:
A20121025.txt
20121025A.txt
ABC20121025.txt
20121025ZYX.txt
ZYX20121025XYZ.txt
If the file name stays the same as the original file: 20121025.txt, then there is no error.
Regarding the issue of changing the date of the file, I have looked at the links you posted, and searched for posts matching "SetFileTimeModified". Unfortunately, it's all going way over my head. The more I read, the more confusing it all becomes.
I tried adding the line: SetFileTimeModified(FileName, dtDateOrg); to your code. It does not give me any errors, but it also does not do anything to the actual file date either. From what I have read in your code, FileName should be the full name of the file and the dtDateOrg should be value of the date from the file name. So, I thought it might have a (slim) chance of working.
I'll continue to play around with it and maybe get lucky and find some code that works for me. If not, I'd post a new topic as per your suggestion.
Thanks and Regards,
Ken
Offline
Thanks for the new example file names, I have added better error handling now,
as the first code works only with before provided examples. See script B on the post above.
For SetFileTimeModified() I will provide you something as soon as I get some free time ( in 7 hours? )
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Thank you for feedback Stefan.
I understand if you're busy. No huge hurry on my part. Just was something that I thought would be nice to help with the actual sort order and readability when viewing the folder using Explorer.
The main thing was actually getting the date changed as what you had done for me earlier.
Regards,
Ken
Offline
Ah, yes,sorry. Here is the code, just add him (or 'it' ?) between the old code at place shown here in blue color:
sRest := ReplaceRegEx(sDateNew, '(\w+\b)(.+)','$2',false,true);
sRest := WideUpperCase(sRest);
//Set timestamp according to extracted date:
SetFileTimeCreated(FilePath,dtDateOrg);
SetFileTimeModified(FilePath,dtDateOrg);
//rename the file (here as dummy example only)
FileName := sPartBefore + sDDDD + ' - ' + sRest + sPartAfter + WideExtractFileExt(FileName);
@Denis, All
Wiki says: SetFileTimeModified(const FileName: WideString; const DateTime: TDateTime);
but I see it has to be SetFileTimeModified(const FilePath: WideString; const DateTime: TDateTime);
So, should I modify the wiki accordingly?
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Wiki says: SetFileTimeModified(const FileName: WideString; const DateTime: TDateTime);
but I see it has to be SetFileTimeModified(const FilePath: WideString; const DateTime: TDateTime);So, should I modify the wiki accordingly?
FileName is a generic parameter and is commonly used in Delphi, Pascal Script, Free Pascal routines in place where a path or a name to a file is needed. It is better to leave it as is to conform with this standard. You will notice that all other functions also use a FileName parameter. So there is no need to change it.
Offline