Timestamp sync-ing

Discuss and share scripts and script files...
Post Reply
prino
Posts: 354
Joined: 18 Mar 2012 21:14
Location: Vilnius, Lithuania
Contact:

Timestamp sync-ing

Post by prino »

Is there a smart way using a script to set all timestamps of all files in a folder (on a file by file basis) to the "Modified" timestamp of each file.

Why?

Many archives only store the "modilfied" timestamp and when these are unarchived the other two (created & accessed) are set to "now", which leads to the curious situation than a file is modified before it's created. Using the properties this is correctable via cut&paste, but doing so for large archives is a bit tedious.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
At last, a tiny bit of programming here... :mrgreen:

highend
Posts: 14594
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Timestamp sync-ing

Post by highend »

::msg property("Write");

Use that in the address bar after selecting one of your files and tell me if it delivers the time that you want to set.
One of my scripts helped you out? Please donate via Paypal

prino
Posts: 354
Joined: 18 Mar 2012 21:14
Location: Vilnius, Lithuania
Contact:

Re: Timestamp sync-ing

Post by prino »

highend wrote:::msg property("Write");

Use that in the address bar after selecting one of your files and tell me if it delivers the time that you want to set.
Yes, it does
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
At last, a tiny bit of programming here... :mrgreen:

highend
Posts: 14594
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Timestamp sync-ing

Post by highend »

EDIT: Please post a timestamp from a few of your files (I want to see which format is used on your locale)

Create a new folder, copy one of your files to this folder, jump into this folder.

Use the script.

Get the properties tab of this file and check if all times are exactly equal to the modified time of your file.
If not, change $hMod and $sMod to accommodate your time differences (hMod = +- modified hours, the same for seconds).

Repeat the process until everything is right.

If you don't want the script to set the timestamps recursively, remove the second "r" in the:

Code: Select all

$files = folderreport("files", "r", , "r", , "|");
line!

Use it at your own risk, too lazy to implement any checks now :)

I' have to modify it a bit to avoid non allowed times... Stay tuned.

[/code]
One of my scripts helped you out? Please donate via Paypal

prino
Posts: 354
Joined: 18 Mar 2012 21:14
Location: Vilnius, Lithuania
Contact:

Re: Timestamp sync-ing

Post by prino »

Script seems to have fallen through?

Anyway, my timestamps are of the "2012-01-20 17:38:06" format
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
At last, a tiny bit of programming here... :mrgreen:

highend
Posts: 14594
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Timestamp sync-ing

Post by highend »

Script seems to have fallen through?
No, I've removed it intentionally.

Code: Select all

	$hMod = "";
	$sMod = "";
	$files = folderreport("files", "r", , , , "|");
	$string = "";
	foreach($item, $files, "|") {
		$mTime = property("Write", $item);
		$nDate = gettoken($mTime, 1, " ");
		$nTime = gettoken($mTime, 2, " ");
		$nmTime = (gettoken($nTime, 1, ":") + $hMod) . ":" . gettoken($nTime, 2, ":") . ":" . gettoken($nTime, 3, ":") + $sMod;
		timestamp ca, "$nDate $nmTime", $item;
		$string = $string . $item . " was set to: " . "$nDate $nmTime" . <crlf>;
	}
	text $string;
Use it with ONE single file in a test folder! After running it, tell me if you see any time differences. If everything is ok, you can use it on a normal folder. I removed the recursive flag in the folderreport command myself.
One of my scripts helped you out? Please donate via Paypal

prino
Posts: 354
Joined: 18 Mar 2012 21:14
Location: Vilnius, Lithuania
Contact:

Re: Timestamp sync-ing

Post by prino »

It works and it doesn't work... Some timestamps are OK, but for most the created & modified times are one or two seconds more, and setting a timestamp to "23:59:59" will result in a error-box with "Invalid date: yyyy-mm-dd 0::0". Looking at the script (as a complete newbie) I cannot really see why this would be happening.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
At last, a tiny bit of programming here... :mrgreen:

highend
Posts: 14594
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Timestamp sync-ing

Post by highend »

It has nothing to do with the script itself. I have the same issues because of the 2 sec time difference.

E.g.:
The original modified time property shows: 16:05:07
but if I overwrite it with ::timestamp m, "19.04.2012 16:05:07";

the new stamp will be 16:05:09;

It's a windows "feature"...

It can be fixed but you have to do a few more tests. I must know if the time difference (seconds or hours) are always the same or if they differ (sometimes 1 second, sometimes 2 or if the hour can be two hours off as well).

If that's the case, $hMod and $sMod could be set to accommodate these changes but I have to rewrite the script to check for time boundaries (e.g. 59 seconds original, the new time must be 1 minute, 1 second (on a two second time difference)).
One of my scripts helped you out? Please donate via Paypal

prino
Posts: 354
Joined: 18 Mar 2012 21:14
Location: Vilnius, Lithuania
Contact:

Re: Timestamp sync-ing

Post by prino »

Explain the "windows feature^H^H^H^H^H^Hannoyance", as it doesn't occur with any other timestamp changing tools (Romain Petges "Attribute Changer", kish "PropertiesPlus", GNU's touch) and of course the properties pane in XY.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
At last, a tiny bit of programming here... :mrgreen:

highend
Posts: 14594
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Timestamp sync-ing

Post by highend »

I don't think that that Don recreated a timestamp writing feature instead of calling a windows function for it.

https://startpage.com/do/search?languag ... difference

If any of these utilities correct this issue by themselfes, fine, use them.
One of my scripts helped you out? Please donate via Paypal

prino
Posts: 354
Joined: 18 Mar 2012 21:14
Location: Vilnius, Lithuania
Contact:

Re: Timestamp sync-ing

Post by prino »

highend wrote:I don't think that that Don recreated a timestamp writing feature instead of calling a windows function for it.

https://startpage.com/do/search?languag ... difference

If any of these utilities correct this issue by themselfes, fine, use them.
Don's do-it-in-the properties pane (using Cut&Paste) works flawlessly, but it's just not suitable for doing it to dozens of files created from unzipping an archive.

And as for the utilities which don't have the seconds-off issue,
  • All of them can process a whole directory, but cannot do the whole-directory processing on a file-by-file basis
  • GNU's touch cannot change the creation date
  • PropertiesPlus and Attribute Changer only work as GUI
  • PropertiesPlus no longer works on W64
  • Attribute Changer is 64-bit shell extension and as such doesn't work in XY
Is there a way to invoke a program from a script for every file in a directory, passing it the modified timestamp as argument? If yes, then I found something that might do the trick, Touch32, a command-line touch utility that can set all three dates.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
At last, a tiny bit of programming here... :mrgreen:

highend
Posts: 14594
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Timestamp sync-ing

Post by highend »

Help - Advanced Topics - Scripting Commands Reference - get & run

and

Help - Advanced Topics - Scripting - Control Structures - Foreach Loops

Enough to get it running.
One of my scripts helped you out? Please donate via Paypal

prino
Posts: 354
Joined: 18 Mar 2012 21:14
Location: Vilnius, Lithuania
Contact:

Re: Timestamp sync-ing

Post by prino »

Thank you for the pointer, if I get stuck I'll come back.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
At last, a tiny bit of programming here... :mrgreen:

Post Reply