...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).
" as for time.
folder.
Cosmetics: now keyboard-driven.
.
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"
@Don: what about a clock as internal icon? (:clock); are you open for other suggestions regarding internal icons requests?