modified date script help

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
jsc572
Posts: 67
Joined: 16 Feb 2007 01:31

modified date script help

Post by jsc572 »

Hello, I need a quick script to append date that is a day before the file was modified, so if a file was modified today, the append date would be yesterday (today-1).

how do I modify below script to do just that? thx.
|"append modified date" \;*>::rename "b", "* <datem mm-dd-yy>"

admin
Site Admin
Posts: 65084
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: modified date script help

Post by admin »

jsc572 wrote:Hello, I need a quick script to append date that is a day before the file was modified, so if a file was modified today, the append date would be yesterday (today-1).

how do I modify below script to do just that? thx.
|"append modified date" \;*>::rename "b", "* <datem mm-dd-yy>"
You'd need some DateDiff function to get this right. This is currently not supported by scripting.
Strange wish, BTW. :)

jsc572
Posts: 67
Joined: 16 Feb 2007 01:31

Re: modified date script help

Post by jsc572 »

admin wrote: You'd need some DateDiff function to get this right. This is currently not supported by scripting.
Strange wish, BTW. :)
I'm the living oracle of excel, guess I'm trying too hard to solve everything with formula :)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: modified date script help

Post by jacky »

admin wrote:You'd need some DateDiff function to get this right. This is currently not supported by scripting.
Strange wish, BTW. :)
<shameless plug>
Actually, that can be done with common-jacky. Quickly (and untested, but I believe it should work as expected):

Code: Select all

"date"
	$day = <datem dd>;
	sub ($day == 1) ? '_doMonth' : '_nothing';
	end $day == 1,,1;
	substr $day, "0" . ($day - 1), -2;
	rename b, "* <datem mm>-$day-<datem yyyy>";
"_doMonth"
	global $CJ_date, $CJ_day_number;
	$CJ_date = <datem dd/mm/yyyy>;
	load "common-jacky", "_getNumberFromDate";
	$CJ_day_number = $CJ_day_number - 1;
	load "common-jacky", "_getDateFromNumber";
	substr $day, $CJ_date, 0, 2;
	substr $month, $CJ_date, 3, 2;
	substr $year, $CJ_date, -4;
	rename b, "* $month-$day-$year";
"_nothing"
</shameless plug>

That being said, some date functions have been on my list for a while, though I somehow never got to actually wish it here. But on many occasions it could be useful, and the CJ trick while it work just fine, isn't the fastest. Maybe to add on your list somewhere, Don, could be some functions like datediff() & dateadd()
Proud XYplorer Fanatic

admin
Site Admin
Posts: 65084
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: modified date script help

Post by admin »

jacky wrote:Maybe to add on your list somewhere, Don, could be some functions like datediff() & dateadd()
Whoops, yep, dateadd() was the one needed here, not datediff(). Yes, maybe laaaaaater...

jsc572
Posts: 67
Joined: 16 Feb 2007 01:31

Re: modified date script help

Post by jsc572 »

wow, this really works!

jsc572
Posts: 67
Joined: 16 Feb 2007 01:31

Re: modified date script help

Post by jsc572 »

btw, can this script be added to right drag move context menu? and if so, how? thx.

admin
Site Admin
Posts: 65084
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: modified date script help

Post by admin »

jsc572 wrote:btw, can this script be added to right drag move context menu? and if so, how? thx.
No, but maybe later with Custom Event Actions...

Post Reply