Something like this would probably work. Highly untested so use it at your own risk
It should create a nearly perfect clone, attributes and correct file / folder times included...
Code: Select all
// Create a zero-byte clone of the current path in the active pane inside the current path of the inactive pane
// name|size|modified|created|accessed|attributes]
$items = quicksearch(, , , "sm");
end (!$items), "No item(s) in the current path, aborted!";
$dst = gettoken(get("Tabs_sf", <crlf>, "i"), 1, <crlf>);
showstatus 0;
setting "BackgroundFileOps", 0;
// Get all folder(s), remove them from the list and create them
// Do not set the timestamps here! Creating items in them will change them anyway...
$folders = regexmatches($items, "^(.+?\|){5}.*?D.*?(?=\r?\n|$)", <crlf>);
if ($folders) {
$items = regexreplace($items, "^(.+?\|){5}.*?D.*?(\r?\n|$)");
status "Creating folder(s)...", , "progress";
foreach($folder, $folders, <crlf>, "e") {
// We need to remove the current path to make them relative to $dst
$path = gettoken($folder, 1, "|");
$path = replace($path, <curpath> . "\");
$attribs = gettoken($folder, 6, "|");
$newDst = $dst . "\" . $path;
if (new($newDst, "dir")) { attrstamp($attribs, 2, $newDst); }
wait 1;
}
}
// Now do all file(s)
if ($items) {
status "Creating file(s)...", , "progress";
foreach($item, $items, <crlf>, "e") {
$path = gettoken($item, 1, "|");
$path = replace($path, <curpath> . "\");
$modified = gettoken($item, 3, "|");
$created = gettoken($item, 4, "|");
$accessed = gettoken($item, 5, "|");
$attribs = gettoken($item, 6, "|");
$newDst = $dst . "\" . $path;
if (new($newDst, "file")) {
attrstamp($attribs, 2, $newDst);
timestamp "c", $created, $newDst;
timestamp "m", $modified, $newDst;
timestamp "a", $accessed, $newDst;
}
wait 1;
}
}
// Finally set timestamps for the folder(s)
if ($folders) {
// Reverse them to be able to do the deeper paths first
$folders = formatlist($folders, "v", <crlf>);
status "Timestamping folder(s)...", , "progress";
foreach($folder, $folders, <crlf>, "e") {
$path = gettoken($folder, 1, "|");
$path = replace($path, <curpath> . "\");
$modified = gettoken($folder, 3, "|");
$created = gettoken($folder, 4, "|");
$accessed = gettoken($folder, 5, "|");
$newDst = $dst . "\" . $path;
timestamp "c", $created, $newDst;
timestamp "m", $modified, $newDst;
timestamp "a", $accessed, $newDst;
wait 1;
}
}
status "DONE...";