STILL BETA! But THIS VERSION WORKS! (except if you have a large number of folders/files to deal with...

See
below for more info.)
*WARNING* - read the original topic. THIS WILL ERASE THE ENTIRE FOLDER WHERE IT'S LAUNCHED FROM, PLUS SUBFOLDERS! BE WARNED!
EDIT: Put the whole code as comment - so you'll really won't want to blame me if things doesn't happen the way you expected. BE SURE on WHAT YOU DO WITH THIS LITTLE DEVIL!
_______________________
TAKE CARE!!!_______________________
________________________

666 :twisted:________________________
(and try not to harm any ex-girlfriend or roommate, too... lol)
***You can use ESC to abort its execution at anytime (ah, IF ONLY I had it in my veins when this thing ate some files, inadvertently...

).***
Code: Select all
/*
"Catalog Maker v 1.0 - Code by TheQwerty, Stefan and Jacky; re-sampled by SkyFrontier"
#263; //show all items in branch
#485; //refresh file list
sel f; //selects all files, no folders
#485; //refresh file list
end(getinfo("CountSelected") < 1), "Please select some files first.";
////get name, creation date and modification date from selected files:
$Records = report("{Fullname}, {Created}, {Modified}<crlf>",1);
$Records = "{Fullname}, {Created}, {Modified}<crlf>" . $Records;
////write to an file "__timestamps" into current folder:
writefile("<xydata>\_RES\Temp\__timestamps", $Records);
////cosmetics:
//status "Get timestamps is done.";
sel f; End GetInfo("CountSelected") < 1, "No item(s) selected.";
Global $files;
$files = Report("{Dir |{FullName};{Ext}<crlf>|}", 1);
Setting "AllowRecursion", 1;
Sub "_ZERO";
$files = RegexReplace($files, "^(.*);.*<crlf>", "$1|");
Delete 1,1,$files;
focus l;
#485; //refresh file list
sel f; //selects all files, no folders.
rename s, "-01/";
sel f;
////load info from an file "__timestamps" in current folder:
$Records = readfile("<xydata>\_RES\Temp\__timestamps");
////For Each Item in Itemlist $Records DO:
$LOOP=2;
while(1)
{
////Get next record set:
$RecSet = gettoken($Records, $LOOP, "<crlf>");
if ($RecSet==""){break;}
////split the record into parts and get
////the file name (and add the current path):
$file = gettoken($RecSet, 1, ",");
////the creation date:
$cDate = gettoken($RecSet, 2, ",");
////set the creation date to $file:
timestamp c, "$cDate", "$file";
////the modification date:
$mDate = gettoken($RecSet, 3, ",");
////set the modification date to $file:
timestamp m, "$mDate", "$file";
incr $LOOP;
}
////cosmetics:
status "Set timestamps is done. Catalog created!";
//while($loop<3){beep; beep 1000, 200;beep 1200, 400;incr $loop;wait 500;}
"_ZERO"
Global $files, $i;
$i = $i Like "" ? 1 : $i;
$token = GetToken($files, $i, "<crlf>");
End $token Like "",, 1;
$file = GetToken($token, 1, ";");
$ext = GetToken($token, 2, ";");
$newFile = RegexReplace($file, "$ext$", "$ext");
New $newFile;
$i = $i + 1;
Sub "_ZERO";
*/
Code: Select all
Notes:
"Catalog Maker v 1.0 - Code by TheQwerty, Stefan and Jacky, re-sampled by SkyFrontier"
#263; //show all items in branch
Bloat? #485; //refresh file list
Bloat? sel f; //selects all files, no folders
Bloat? #485; //refresh file list
------
New: $Records = report("{Fullname}, {Created}, {Modified}<crlf>",1);
$Records = "{Fullname}, {Created}, {Modified}<crlf>" . $Records;
Previous: $Records = report("{Name}, {Created}, {Modified}<crlf>",1);
$Records = "{Name}, {Created}, {Modified}<crlf>" . $Records;
effect: was not allowing recursive work.
------
New: Delete 1,1,$files;
focus l;
#485; //refresh file list
sel f; //selects all files, no folders.
Previous: Delete 1,1,$files;
sel f; //selects all files, no folders.
effect: allows selection of ALL files in list for renaming
------
New: $file = gettoken($RecSet, 1, ",");
Previous: $file = "<curpath>\" . gettoken($RecSet, 1, ",");
effect: avoids conflict with required report(Fullname) info, above.
Yet to confirm:
-can someone please clean out the code, if necessary?
-Stefan, what's the function of the "while($loop<3){beep; beep 1000, 200;beep 1200, 400;incr $loop;wait 500;}" part of the code? -"while" stands for telling the script to repeat the beeping, only?
-can someone please provide a confirmation box telling that "x" files will be zeroed, asking to cancel or continue?
-wasn't supposed that
writefile("<xydata>\_RES\Temp\__timestamps" could create the folder
in case of it being non-existent? Or at least ask for its creation? It works that way in some cases, but
not in others, and could happen when entering a (non-existent) path directly (CTRL+C) into address bar plus pressing enter.
Thank you!
Tag - xyScript