Page 1 of 2

Easier way to deal with Timestamping.

Posted: 10 Oct 2010 12:24
by SkyFrontier
It's so natural to me trying to do this that I'm surprised it's not supported (it's the 3rd or 4th time over the last month I'm trying to unsuccessfully do the same thing).
-what about a way to timestamp m, "c"/timestamp ma, c?
Thank you!

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 12:41
by admin
SkyFrontier wrote:... -what about a way to timestamp m, "c"/timestamp ma, c?
:? What? You talk about scripting?

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 12:57
by SkyFrontier
Yes. Using simply timestamp m, "c" instead of timestamp m, "2008-12-31 08:22:15", being 2008-12-31 08:22:15 actual value of c (creation date), in this case.

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 13:22
by SkyFrontier
-well, consider that my aim is using timestamping from Address Bar, not a whole script that grabs a value and deals with it guided by several lines...

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 16:41
by serendipity
SkyFrontier wrote:-well, consider that my aim is using timestamping from Address Bar, not a whole script that grabs a value and deals with it guided by several lines...
Ofcourse it can be one line:
timestamp (m, report ("{created}",1));//change modified date to created

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 16:44
by admin
serendipity wrote:
SkyFrontier wrote:-well, consider that my aim is using timestamping from Address Bar, not a whole script that grabs a value and deals with it guided by several lines...
Ofcourse it can be one line:
timestamp (m, report ("{created}",1));//change modified date to created
Or like this:

Code: Select all

#1037;
:wink:

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 17:01
by serendipity
admin wrote:
serendipity wrote:
SkyFrontier wrote:-well, consider that my aim is using timestamping from Address Bar, not a whole script that grabs a value and deals with it guided by several lines...
Ofcourse it can be one line:
timestamp (m, report ("{created}",1));//change modified date to created
Or like this:

Code: Select all

#1037;
:wink:
lol true! Another forgotten trick.
With my method you get other combinations too.

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 18:16
by TheQwerty

Code: Select all

timestamp 'm', "<datec>";

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 19:07
by SkyFrontier
I was trying to adapt the Mexican Deletion Tool or the Catalog Maker to get a full timestamping tool.
Don's solution was limited to the original topic (timestamp m, "c"; of course!) but applies to several files at once.
serendipity's was flexible but limited to one file at a time.
TheQwerty's seem to be both flexible and can be applied to selected files.
Here it goes (with separators and icons as cosmetics):

Code: Select all

"Timestamp Modified as Created|:paste"
   timestamp 'm', "<datec>";
"Timestamp Modified and Accessed as Created|:paste"
   timestamp 'ma', "<datec>";
"Timestamp Modified as Accessed|:paste"
   timestamp 'm', "<datea>";
-
"Timestamp Created as Accessed|:cat"
   timestamp 'c', "<datea>";
"Timestamp Created as Modified|:cat"
   timestamp 'c', "<datem>";
-
"Timestamp Accessed as Modified|:undo"
   timestamp 'a', "<datem>";
"Timestamp Accessed and Created as Modified|:undo"
   timestamp 'ca', "<datem>";
"Timestamp Accessed as Created|:undo"
   timestamp 'a', "<datec>";
v1 (based off serendipity's solution; raw):

Code: Select all

"Timestamp Modified as Created"
   timestamp (m, report ("{created}",1));
"Timestamp Modified and Accessed as Created"
   timestamp (ma, report ("{created}",1));
"Timestamp Created as Modified"
   timestamp (c, report ("{modified}",1));
"Timestamp Accessed and Created as Modified"
   timestamp (ca, report ("{modified}",1));
"Timestamp Accessed as Modified"
   timestamp (a, report ("{modified}",1));
"Timestamp Accessed as Created"
   timestamp (a, report ("{created}",1));
"Timestamp Modified as Accessed"
   timestamp (m, report ("{accessed}",1));
"Timestamp Created as Accessed"
   timestamp (c, report ("{accessed}",1));
Thank you, guys! :D

Re: Easier way to deal with Timestamping.

Posted: 10 Oct 2010 21:53
by SkyFrontier
...and this will be for a complex timestamping/user-definable values or something else that comes up to mind. Feel free to add your suggestions (I'll add them all as for editing).
Note: "accessed" date will always have "00:00:00" as for time.
Note 2: Edit this Script will only work if this script is put and loaded from <xyscripts> folder.
Cosmetics: now keyboard-driven. 8)

Code: Select all

"&Enter Date and Attribs to TimeStamp|:rename"
   input $dt, "Enter Date to be Set", "201y-0m-0d 0h:10:02";
   input $at, "Attribs/set: a(cc.)/m(od.)/c(r.); blank for ALL; dual in any order/combination", "m";
   timestamp $at, $dt;
-
"Timestamp Modified as C&reated|:paste"
   timestamp 'm', "<datec>";
"Timestamp Modified and Accessed as Crea&ted|:paste"
   timestamp 'ma', "<datec>";
"Timestamp Modified as &Accessed|:paste"
   timestamp 'm', "<datea>";
-
"Timestamp Created as A&ccessed|:cat"
   timestamp 'c', "<datea>";
"Timestamp Created as &Modified|:cat"
   timestamp 'c', "<datem>";
-
"Timestamp Accessed as M&odified|:undo"
   timestamp 'a', "<datem>";
"Timestamp Accessed and Created as Modi&fied|:undo"
   timestamp 'ca', "<datem>";
"Timestamp Accessed as Create&d|:undo"
   timestamp 'a', "<datec>";
-
"Timestamp ALL to &NOW|:savesett"
   timestamp
-
"Edit this &script|:udc"
   self $editThis, file;
   OpenWith "notepad", ,$editThis;
-
"CANCE&L"
...and this one combines other stuff from here and there.
To do: full/better keyboard accelerators; little bug with the section/function "Set Modified to Next Day of Current (no time) : TouchModifiedNextDay" part

Code: Select all

"&Enter Date and Attribs to TimeStamp|:rename"
   input $dt, "Enter Date to be Set", "201y-0m-0d 0h:10:02";
   input $at, "Attribs/set: a(cc.)/m(od.)/c(r.); blank for ALL; dual in any order/combination", "m";
   timestamp $at, $dt;
-
"Timestamp Modified as C&reated|:paste"
   timestamp 'm', "<datec>";
"Timestamp Modified and Accessed as Crea&ted|:paste"
   timestamp 'ma', "<datec>";
"Timestamp Modified as &Accessed|:paste"
   timestamp 'm', "<datea>";
-
"Timestamp Created as A&ccessed|:cat"
   timestamp 'c', "<datea>";
"Timestamp Created as &Modified|:cat"
   timestamp 'c', "<datem>";
-
"Timestamp Accessed as M&odified|:undo"
   timestamp 'a', "<datem>";
"Timestamp Accessed and Created as Modi&fied|:undo"
   timestamp 'ca', "<datem>";
"Timestamp Accessed as Create&d|:undo"
   timestamp 'a', "<datec>";
-
"Timestamp ALL attribs to &NOW|:savesett"
   timestamp;
"Set Modified to Now|:paste"
   timestamp m;
"Set Created to Now|:cat"
   timestamp c;
"Set Accessed to Now|:undo"
   timestamp a;
-
"Set Created to Modified (no time)|:cat : TouchCreatedToModified"
   Setting "AllowRecursion", 1;
   global $type_gbl, $group_gbl, $new_date_gbl;
   $type_gbl = "c"; // Created
   $group_gbl = 2; // Pattern for all items
   $new_date_gbl = "m!"; // Modified, Time reset
   sub _touchStart;
"Set Modified to Tomorrow (no time)|:redo : TouchModifiedTomorrow"
   Setting "AllowRecursion", 1;
   global $day_number_gbl, $date_gbl;
   // Today
   $date_gbl = <date dd/mm/yyyy>;
   load Dates, _getNumberFromDate;
   // Tomorrow
   $day_number_gbl = $day_number_gbl + 1;
   load Dates, _getDateFromNumber;
   // direct touch
   timestamp m, $date_gbl;
   // done
   status "Timestamping complete";
">>TO FIX: Set Modified to Next Day of Current (no time)|:stop : TouchModifiedNextDay"
   Setting "AllowRecursion", 1;
   global $type_gbl, $group_gbl, $new_date_gbl;
   $type_gbl = "m"; // Modified
   $group_gbl = 1; // Value for all items
   $new_date_gbl = "+1m!"; // Modified + 1 day
   sub _touchStart;
"Append Yesterday's Date (rel. MOD. attrib.) to Name|:rename"
   Setting "AllowRecursion", 1;
   $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"
   Setting "AllowRecursion", 1;
   global $CJ_date, $CJ_day_number;
   $CJ_date = <datem dd/mm/yyyy>;
   $CJ_day_number = $CJ_day_number - 1;
   substr $day, $CJ_date, 0, 2;
   substr $month, $CJ_date, 3, 2;
   substr $year, $CJ_date, -4;
   rename b, "* $month-$day-$year";
"_nothing"
-
"Change Created Date... (Pattern)|:cat : TouchCreatedPattern"
   Setting "AllowRecursion", 1;
   global $type_gbl, $group_gbl;
   $type_gbl = "c";
   $group_gbl = 2;
   sub _touchStart;
"Change Modified Date... (Pattern)|:paste : TouchModifiedPattern"
   Setting "AllowRecursion", 1;
   global $type_gbl, $group_gbl;
   $type_gbl = "m";
   $group_gbl = 2;
   sub _touchStart;
"- : _sep"
"Change Created Date... (Value)|:cat : _TouchCreatedValue"
   Setting "AllowRecursion", 1;
   global $type_gbl, $group_gbl;
   $type_gbl = "c";
   $group_gbl = 1;
   sub _touchStart;
"Change Modified Date... (Value)|:paste : _TouchModifiedValue"
   Setting "AllowRecursion", 1;
   global $type_gbl, $group_gbl;
   $type_gbl = "m";
   $group_gbl = 1;
   sub _touchStart;
"- : _sep"
"Change Created Date... (Options)|:cat : _TouchCreatedOpts"
   Setting "AllowRecursion", 1;
   global $type_gbl;
   $type_gbl = "c";
   sub _touchStart;
"Change Modified Date... (Options)|:paste : _TouchModifiedOpts"
   Setting "AllowRecursion", 1;
   global $type_gbl;
   $type_gbl = "m";
   sub _touchStart;
-
"Show Full Menu...|:qfv"
   load *,*;


"_touchStart"
   Setting "AllowRecursion", 1;
   global $list_gbl, $group_gbl;
   // set options if not done already
   sub ( $group_gbl == "" ) ? "_touchOptions" : "_nothing";
   // creates the list to work with : Full path/name and the dates of references, already formatted
   $list_gbl = report("{Fullname}{Created dd/mm/yyyyhh:nn:ss}{Modified dd/mm/yyyyhh:nn:ss}|", 1);
   // if current item in selection, move it first so it's the reference one when applied to all selected items at once
   sub (<curitem> == "") ? "_nothing" : "_touchCurItemFirst";
   // go go go
   sub _touchLoop;
   // done
   status "Timestamping complete";
"_touchOptions"
   Setting "AllowRecursion", 1;
   global $group_gbl;
   // set options : 0 = ask pattern/date for all items; 1= calculate date for first item, apply to all items; 2= apply pattern to all items (calculated for each one)
   $group_gbl = (getinfo("CountSelected") > 1) ? confirm("Do you want to touch all selected items at once ?<br><br>OK = All items at once<br>Cancel = All items individually") : 0;
   $group_gbl = ($group_gbl == 1) ? 1 + confirm("Do you want the pattern to be applied to all selected items ?<br><br>OK = Pattern, e.g. m = modified date of each item<br>Cancel = First resolved value, e.g. m = modified date of first item") : 0;
"_touchCurItemFirst"
   Setting "AllowRecursion", 1;
   global $list_gbl;
   // length of path/name
   strlen $l, <curitem>;
   // finds the item
   strpos $p, $list_gbl, <curitem>;
   // items before
   substr $bef, $list_gbl, 0, $p;
   // current item (w/ dates)  37 = dates (36) + pipe
   substr $itm, $list_gbl, $p, $l + 37;
   // items before
   substr $aft, $list_gbl, $p + $l + 37;
   // move current to top of list
   $list_gbl = $itm.$bef.$aft
"_touchLoop"
   Setting "AllowRecursion", 1;
   global $list_gbl, $item_gbl;
   // get end of item's data
   strpos $p, $list_gbl, "|";
   // extract item
   substr $item_gbl, $list_gbl, 0, $p;
   // remove it from list
   substr $list_gbl, $list_gbl, $p + 1;
   // do the work
   sub _touch;
   // continue?
   sub ($list_gbl == "") ? "_nothing" : "_touchLoop";
"_touch"
   Setting "AllowRecursion", 1;
   global $type_gbl, $new_date_gbl, $item_gbl, $dates_gbl, $group_gbl;
   // ensure an item do timestamp
   assert ($item_gbl != ""), "No item selected !";
   // get created/modified dates
   substr $c_date, $item_gbl, -36, -26;
   substr $c_time, $item_gbl, -26, -18;
   substr $m_date, $item_gbl, -18, -8;
   substr $m_time, $item_gbl, -8;
   // for later use in loaded scripts, because I don't want to global them all...
   $dates_gbl = '$c_date = "'.$c_date.'"; $c_time = "'.$c_time.'"; $m_date = "'.$m_date.'"; $m_time = "'.$m_time.'";';
   // get item's path/name & name only
   substr $item, $item_gbl, 0, -36;
   regexreplace $name, $item, "^.+\\([^\\]+)$", "$1";
   
   // ask for new date if needed
   load ( ($new_date_gbl == "") ? ('global $type_gbl, $new_date_gbl, $group_gbl; '.$dates_gbl.' input $new_date_gbl, (($type_gbl == "m") ? "Modified" : "Created") . " ".(($group_gbl == 2) ? "pattern" : "date")." for ".(($group_gbl >= 1) ? (getinfo("CountSelected") . " selected items") : """'.$name.'""")."  |  [empty] = Now; ! = Reset time; +/-[0-9][cm]! = Maths", "$'.$type_gbl.'_date $'.$type_gbl.'_time";') : 'call'),,s;
   // trick so that an empty pattern canbe applied in batch without cause a prompt
   $new_date_gbl = ($new_date_gbl == "Now") ? "" : $new_date_gbl;
   
   // save pattern (might need to restore it once done with this item)
   $pattern = $new_date_gbl;
   
   // deal with operations ( +/- [0-9] [cm] ! )
   substr $sign, $new_date_gbl, 0, 1;
   sub ( ($sign == "+") + ($sign == "-") == 1 ) ? "_touchOp" : "_nothing";
   
   // set to modified/created date (with !-suffix to reset time)
   load ( ( ($sign == "m") + ($sign == "c") == 1 ) ? ('global $new_date_gbl; '.$dates_gbl.' substr $new_date_gbl, $new_date_gbl, 1; $new_date_gbl = "$'.$sign.'_date ".(($new_date_gbl == "!") ? "00:00:00" : "$'.$sign.'_time");') : 'call'),,s;
   
   // reset hour
   load ( ($new_date_gbl == "!") ? ('global $new_date_gbl; '.$dates_gbl.' $new_date_gbl = "$'.$type_gbl.'_date 00:00:00";') : 'call'),,s;
   
   // touching -- if group == 1 then touch all items and be done with it already, otherwise it's this one item and moving on to the next...
   self $file, file;
   load ( ( $group_gbl == 1) ? ('global $tmp_gbl; $tmp_gbl = "'.$item.'"; load "'.$file.'", "_touchAll";') : "timestamp $type_gbl, ""$new_date_gbl"", ""$item"";" ),,s;
   
   // restore for when looping -- w/ trick so that an empty pattern canbe applied in batch without cause a prompt
   $new_date_gbl = ($group_gbl == 0) ? "" : (($group_gbl == 1) ? (($new_date_gbl == "") ? "Now" : $new_date_gbl) : (($pattern == "") ? "Now" : $pattern));
"_touchOp"
   Setting "AllowRecursion", 1;
   global $type_gbl, $new_date_gbl, $item_gbl, $date_gbl, $day_number_gbl, $tmp_gbl;
   // get created/modified dates
   substr $c_date, $item_gbl, -36, -26;
   substr $c_time, $item_gbl, -26, -18;
   substr $m_date, $item_gbl, -18, -8;
   substr $m_time, $item_gbl, -8;
   // sign
   substr $sign, $new_date_gbl, 0, 1;
   // remove sign from value
   substr $tmp_gbl, $new_date_gbl, 1;
   // get flag ( ! == reset time )
   substr $flag, $tmp_gbl, -1;
   // if flag found, remove it from value
   load (($flag == "!") ? 'global $tmp_gbl; substr $tmp_gbl, $tmp_gbl, 0, -1;' : 'call'),,s;
   // get last char, might be type (c/m)
   substr $type, $tmp_gbl, -1;
   // if type not specified, we add it
   load ( ( ($type == "m") + ($type == "c") == 0 ) ? 'global $tmp_gbl, $type_gbl; $tmp_gbl = $tmp_gbl.$type_gbl;' : 'call'),,s;
   // now get value (all minus type)
   substr $value, $tmp_gbl, 0, -1;
   // and get type
   substr $type, $tmp_gbl, -1;
   
   // get reference date
   $date_gbl = eval('$'.$type.'_date');
   // calc its day number
   load Dates, _getNumberFromDate;
   // do the maths
   $day_number_gbl = eval("$day_number_gbl $sign $value");
   // get the new date back
   load Dates, _getDateFromNumber;
   // return it, with time unless flagged to reset
   $new_date_gbl = "$date_gbl " . (($flag == "!") ? "00:00:00" : eval('$'.$type.'_time'));
"_touchAll"
   Setting "AllowRecursion", 1;
   global $type_gbl, $new_date_gbl, $tmp_gbl, $list_gbl;
   // removes dates from list
   regexreplace $list_gbl, $list_gbl, "(.+?).{36}(\|)", "$1$2";
   // remove last pipe
   substr $list_gbl, $list_gbl, 0, -1;
   // add the extracted item
   $list_gbl = ($list_gbl == "") ? $tmp_gbl : "$tmp_gbl|$list_gbl";
   // touch
   timestamp $type_gbl, $new_date_gbl, $list_gbl;
   // and done!
   $list_gbl = "";
"_nothing"
-
"Edit this &script|:udc"
   self $editThis, file;
   OpenWith "notepad", ,$editThis;
-
"CANCE&L"
-
"Cancel"
TimestampingSuite.xys
@Don: what about a clock as internal icon? (:clock); are you open for other suggestions regarding internal icons requests?
Thank you!

Re: Easier way to deal with Timestamping.

Posted: 11 Oct 2010 10:28
by SkyFrontier
In the above script I added the

Code: Select all

-
"CANCE&L"
-
"Cancel"
method because if I add the keyboard accelerator the menu item is grayed and not clickable; if I remove the key-accel. I can click it but (of course!) losing the functionality. Can this be fixed/circumvented?
Thanks!

Re: Easier way to deal with Timestamping.

Posted: 18 Oct 2010 20:39
by SkyFrontier
Timestamping Suite, v2, final (at least until someone can help me fixing a little problem...)
For the EXIF related function, you may want to use this sample file for test purposes:
EXIFedSample.jpg
(source: http://www.robogeo.com/home/stamp2.jpg)

It has the following options:

Code: Select all

Enter Date and Attribs to Timestamp
 -
Timestamp Modified as Created
Timestamp Modified and Accessed as Created
Timestamp Modified as Accessed
Timestamp Created as Accessed
Timestamp Created as Modified
Timestamp Accessed as Modified
Timestamp Accessed and Created as Modified
Timestamp Accessed as Created
 -
Timestamp ALL attribs to NOW
Set Modified to Now
Set Created to Now
Set Accessed to Now
 -
Timezoned Timestamping from EXIF
Determine the Zodiac Sign of a File
 -
Set Created to Modified (no time)
Set Modified to Tomorrow (no time)
Append Yesterday's Date (rel. MOD. attrib.) to Name
 -
Change Created Date... (Pattern)
Change Modified Date... (Pattern)
>>on submenu:
Change Created Date... (Value)
Change Modified Date... (Value)
Change Created Date... (Options)
Change Modified Date... (Options)
 -
Edit this Script
Changes:
>Removed Set Modified to Next Day of Current (can't fix it);
>Added "dates.xys" dependency content into the script itself as a comment (need to be placed externally under <xyscripts> folder so the whole suite can work;
>Added Timezoned Timestamping from EXIF function (I'd prefer an HTML interface, but this is what I can do for after getting nowhere with the HTML thing... :| );
>Added Determine the Zodiac Sign of a File function (a little exercise...);
>Fixed some key accelerators conflicts.
Bugs:
-Key accelerators not being displayed... :?
-"Cancel" function seems to have some limitations (described in the previous post).

Re: Easier way to deal with Timestamping.

Posted: 19 Oct 2010 06:49
by SkyFrontier
v3:
-Added "Set Modified to Yesterday".
-Changed icons to match previous change: Set Modified to Yesterday|:back, Set Modified to Tomorrow|:fore.
>1st attempt to have user definable option for this, failed (added as comment).

Re: Easier way to deal with Timestamping.

Posted: 27 Oct 2010 00:38
by SkyFrontier
v4:
-added Sync Timestamps functionality, v2 - this one can apply timestamp on several target items at once, plus having a reminder on basic setup for it to work properly (still pending full support to several items at once on both source/target = full timestamp sync'ing);
-fixed the "cancel" problem (thanks to TheQwerty's tips);
-minor changes regarding layout.

Re: Easier way to deal with Timestamping.

Posted: 03 Nov 2010 17:34
by SkyFrontier
Users interested in this may also want to look at the Sync Timestamps - Multiple Files - req. Script Reloader Mod (not a complete script but a trick involving Sync Timestamps functionality so it can work with multiple files, synchronizing them too).