Page 1 of 1

modified date script help

Posted: 04 Feb 2009 19:40
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>"

Re: modified date script help

Posted: 04 Feb 2009 19:46
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. :)

Re: modified date script help

Posted: 04 Feb 2009 20:03
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 :)

Re: modified date script help

Posted: 04 Feb 2009 20:22
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()

Re: modified date script help

Posted: 04 Feb 2009 20:37
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...

Re: modified date script help

Posted: 05 Feb 2009 03:17
by jsc572
wow, this really works!

Re: modified date script help

Posted: 05 Feb 2009 03:36
by jsc572
btw, can this script be added to right drag move context menu? and if so, how? thx.

Re: modified date script help

Posted: 05 Feb 2009 08:12
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...