Code: Select all
//Function : Move the first item of the two selected items to the specified directory, and the second item to the original directory of the first item (the next two items are automatically selected, and compare the filenames)
//Created : 2022-07-07
//Modified : 2022-07-16
//Version : 1.2
//Set the directory to move the first item to
$item1To = "G:\Folders\Con\";
$item1To = "$item1To" . "\";
$item1To = replace($item1To, "\\", "\");
//Get the two selected items
$items = report("{fullname}<crlf>",1);
//Select the two selected items, making the focused item the first
selectitems $items;
//Compare the filenames
//Get the basenames of the two selected items
$itemsNames = report("{basename}<crlf>",1);
//Calculate the number of <crlf> in $itemsNames
$count = gettoken($itemsNames, "count", "<crlf>");
//Get the first and second item names
$itemName1 = gettoken($itemsNames, 1, "<crlf>");
$itemName2 = gettoken($itemsNames, 2, "<crlf>");
//If the two selected items have different names, or $count is greater than 3, cancel the selection, and then exit the script
if($itemName1 != $itemName2 || $count > "3") {sel; end '1==1', "The two selected items have different names";}
//Each selected item
foreach($item, $items, "<crlf>", "e") {
//If $case equals 2, then
if($case == "2") {
//Move the second item to the original path of the first item
moveto $itemPath, $item, , 2;
}
//If $case is not equal to 2, then
if($case != 2) {
//Get the path of the first item
$itemPath = regexreplace($item, "(.*\\)(.*)(....)", "$1");
//Get the basename of the first item
$itemName = gpc($item, "base");
//Move the first item to the specified directory
moveto "$item1To", $item, , 2;
//Set $case equal to 2
$case = "2";
//Moving files takes time
wait '600';
}
}
//Select next to next
sel "+2";
//Select current item and next
sel +, 2;
//Moving files takes time
wait '600';
//If both items exists at the new location, then
if(exists("$item1To$itemName") == "1" && exists("$itemPath\$itemName") == "1") {
//Play a beep
sound "C:\Windows\Media\Windows Navigation Start.wav", , 1;
//The status bar shows the new full paths for both item
status "$item1To$itemName $itemPath\$itemName";
}