CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Discuss and share scripts and script files...
Post Reply
Jerry
Posts: 834
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by Jerry »

Hi all,
Just sharing this simple script I have been using with great satisfaction. It lets you work with a preset menu of paths that you frequently access and gives you a choice of operations: Go to, Copy or Move. In the latter 2 cases, the operation will work on any items you select in the List. The script has an example menu of paths with separators and a sub menu.

Before I created this script, I was using the Favorite Folders and Recent File Operations menus. But the Recent File Operations menu is dynamically created from the Action log and common paths I use wouldn't necessarily stay there. And Favorite Folders is often slow to popup on my system because most of the paths I use are on external drives which might be asleep. (Don had made improvements to address this, but it's still problematic for me.) Recent File Operations can also be slow to popup sometimes too.

Code: Select all

// This script pops up a menu of destinations and actions (Move, Copy or Go To),
// then performs the chosen operation for the chosen destination
// using selected items if relevant.
// [Created by XYplorer forum Jerry]

//==================================================================
// Define your preset destinations here:
    $destinations = <<<#---MENU_END
Downloads
Documents
Desktop
-
Windows System Folders 
  %appdata%
  %localappdata%
  %temp%
  %programfiles%
  %programfiles(x86)%
#---MENU_END;
//==================================================================

// Check for selected items
   $selcount = gettoken(<selitems |>, "count", "|");

// Ask for Action
    $action = popupmenu("Go To|Copy|Move");
    if ($action == "") { end 1; } // user cancelled

    if ($action == "Go To") {
	   $selcountDisplay = ""
	} else {
	   $selcountDisplay = " (" . $selcount . " items)"
	}

   // Require selected items if necessary
   if ($action != "Go To") {
	   if ($selcount == 0) {
			msg "You must select one or more items for the chosen operation ($action).";
			end 1==1;
	   }
	}

// Build menu of destination names, include the $action with item count as a disabled header
	$menu = recase($action, "upper") . $selcountDisplay . ";;;4<crlf>-<crlf>" . $destinations;

// Show menu of destinations
    $choice = popupnested($menu);
    if ($choice == "") { end 1; } // user cancelled

    $dest = trim($choice);

    if ($action == "Go To") {
	   goto $dest;
	   end 1==1;
	}

// Perform the operation on selected items
    if ($action == "Move") {
        moveto $dest, <get SelectedItemsPathNames |>;
    } elseif ($action == "Copy") {
        copyto $dest, <get SelectedItemsPathNames |>;
    }
Last edited by Jerry on 20 Dec 2025 18:58, edited 1 time in total.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

noembryo
Posts: 178
Joined: 13 Apr 2022 21:40
Location: Windows 10 @100%
Contact:

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by noembryo »

Very useful, thank you for this 🙏
One improvement I would like to see, is a way to be able to display a title instead of the full path.
E.g. Photos instead of D:\In\Data\PhotoEDITS.

Either way, very helpful script.. :appl:
Check my free programs here..

Jerry
Posts: 834
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by Jerry »

noembryo wrote: 20 Dec 2025 16:26 One improvement I would like to see, is a way to be able to display a title instead of the full path.
E.g. Photos instead of D:\In\Data\PhotoEDITS.
Thank you! Yes, you can display a caption instead of the full path. See the change below with the Windows System Folder submenu:

Code: Select all

// This script pops up a menu of destinations and actions (Move, Copy or Go To),
// then performs the chosen operation for the chosen destination
// using selected items if relevant.
// [Created by XYplorer forum Jerry]

//==================================================================
// Define your preset destinations here:
    $destinations = <<<#---MENU_END
Downloads
Documents
Desktop
-
Windows System Folders 
  AppData (Roaming);%appdata%
  AppData (Local);%localappdata%
  Temp;%temp%
  Program Files (64bit);%programfiles%
  Program Files (32bit);%programfiles(x86)%
#---MENU_END;
//==================================================================

// Check for selected items
   $selcount = gettoken(<selitems |>, "count", "|");

// Ask for Action
    $action = popupmenu("Go To|Copy|Move");
    if ($action == "") { end 1; } // user cancelled

    if ($action == "Go To") {
	   $selcountDisplay = ""
	} else {
	   $selcountDisplay = " (" . $selcount . " items)"
	}

   // Require selected items if necessary
   if ($action != "Go To") {
	   if ($selcount == 0) {
			msg "You must select one or more items for the chosen operation ($action).";
			end 1==1;
	   }
	}

// Build menu of destination names, include the $action with item count as a disabled header
	$menu = recase($action, "upper") . $selcountDisplay . ";;;4<crlf>-<crlf>" . $destinations;

// Show menu of destinations
    $choice = popupnested($menu);
    if ($choice == "") { end 1; } // user cancelled

    $dest = trim($choice);

    if ($action == "Go To") {
	   goto $dest;
	   end 1==1;
	}

// Perform the operation on selected items
    if ($action == "Move") {
        moveto $dest, <get SelectedItemsPathNames |>;
    } elseif ($action == "Copy") {
        copyto $dest, <get SelectedItemsPathNames |>;
    }
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

highend
Posts: 14671
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by highend »

Do NOT use a ; as a delimiter, use e.g. |
Why? Paths can contain a semicolon themselves...
One of my scripts helped you out? Please donate via Paypal

Jerry
Posts: 834
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by Jerry »

highend wrote: 20 Dec 2025 16:45 Do NOT use a ; as a delimiter, use e.g. |
Why? Paths can contain a semicolon themselves...
Yes, that was my first choice too, but it doesn't work, at least with the heredoc form of the string. See image and code below. You just get the whole line with the pipe included.

Image

Code: Select all

// This script pops up a menu of destinations and actions (Move, Copy or Go To),
// then performs the chosen operation for the chosen destination
// using selected items if relevant.
// [Created by XYplorer forum Jerry]

//==================================================================
// Define your preset destinations here:
    $destinations = <<<#---MENU_END
Downloads
Documents
Desktop
-
Windows System Folders 
  AppData (Roaming)|%appdata%
  AppData (Local)|%localappdata%
  Temp|%temp%
  Program Files (64bit)|%programfiles%
  Program Files (32bit)|%programfiles(x86)%
#---MENU_END;
//==================================================================

// Check for selected items
   $selcount = gettoken(<selitems |>, "count", "|");

// Ask for Action
    $action = popupmenu("Go To|Copy|Move");
    if ($action == "") { end 1; } // user cancelled

    if ($action == "Go To") {
	   $selcountDisplay = ""
    } else {
	   // Require selected items if necessary for the action
	   if ($selcount == 0) {
			msg "You must select one or more items for the chosen operation ($action).";
			end 1==1;
	   }
	   $selcountDisplay = " (" . $selcount . " items)"
	}

// Build menu of destination names, include the $action with item count as a disabled header
	$menu = recase($action, "upper") . $selcountDisplay . ";;;4<crlf>-<crlf>" . $destinations;

// Show menu of destinations
    $choice = popupnested($menu);
    if ($choice == "") { end 1; } // user cancelled

    $dest = trim($choice);

    if ($action == "Go To") {
	   goto $dest;
	   end 1==1;
	}

// Perform the operation on selected items
    if ($action == "Move") {
        moveto $dest, <get SelectedItemsPathNames |>;
    } elseif ($action == "Copy") {
        copyto $dest, <get SelectedItemsPathNames |>;
    }
Attachments
menu.png
menu.png (27.94 KiB) Viewed 879 times
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

highend
Posts: 14671
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by highend »

Ofc this works...

Code: Select all

// This script pops up a menu of destinations and actions (Move, Copy or Go To),
// then performs the chosen operation for the chosen destination
// using selected items if relevant.
// [Created by XYplorer forum Jerry]

//==================================================================
// Define your preset destinations here:
    $destinations = <<<#---MENU_END
Downloads
Documents
Desktop
-
Windows System Folders
  AppData (Roaming)|%appdata%
  AppData (Local)|%localappdata%
  Temp|%temp%
  Program Files (64bit)|%programfiles%
  Program Files (32bit)|%programfiles(x86)%
#---MENU_END;
//==================================================================

// Check for selected items
   $selcount = gettoken(<selitems |>, "count", "|");

// Ask for Action
    $action = popupmenu("Go To|Copy|Move");
    if ($action == "") { end 1; } // user cancelled

    if ($action == "Go To") {
       $selcountDisplay = ""
    } else {
       // Require selected items if necessary for the action
       if ($selcount == 0) {
            msg "You must select one or more items for the chosen operation ($action).";
            end 1==1;
       }
       $selcountDisplay = " (" . $selcount . " items)"
    }

// Build menu of destination names, include the $action with item count as a disabled header
    $menu = recase($action, "upper") . $selcountDisplay . "|||4<crlf>-<crlf>" . $destinations;

// Show menu of destinations
    $choice = popupnested($menu, 6:=<crlf>, 7:="|");
    if ($choice == "") { end 1; } // user cancelled

    $dest = trim($choice);

    if ($action == "Go To") {
       goto $dest;
       end 1==1;
    }

// Perform the operation on selected items
    if ($action == "Move") {
        moveto $dest, <get SelectedItemsPathNames |>;
    } elseif ($action == "Copy") {
        // copyto $dest, <get SelectedItemsPathNames |>;
    }
One of my scripts helped you out? Please donate via Paypal

noembryo
Posts: 178
Joined: 13 Apr 2022 21:40
Location: Windows 10 @100%
Contact:

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by noembryo »

It works! :appl:
And since we're on the roll, can we have an option to open the goto target in another tab, like middle clicking or ctrl+click? :maf:
(You may be fast, but I'm faster.. :ninja: )
Check my free programs here..

Jerry
Posts: 834
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by Jerry »

Ah, ok. You have to also pass in "|" as the non-default item separator in the call to popupnested:

Code: Select all

$choice = popupnested($menu, 6:=<crlf>, 7:="|");
Didn't know you can pass arguments with the index keyword like that. Good to know.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

Jerry
Posts: 834
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by Jerry »

noembryo wrote: 20 Dec 2025 17:56 And since we're on the roll, can we have an option to open the goto target in another tab, like middle clicking or ctrl+click?
Have to let highend answer that one. I don't see any possible Custom Event Actions for popup menu items in Configuration.
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

noembryo
Posts: 178
Joined: 13 Apr 2022 21:40
Location: Windows 10 @100%
Contact:

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by noembryo »

Jerry wrote: 20 Dec 2025 18:01
noembryo wrote: 20 Dec 2025 17:56 And since we're on the roll, can we have an option to open the goto target in another tab, like middle clicking or ctrl+click?
Have to let highend answer that one. I don't see any possible Custom Event Actions for popup menu items in Configuration.
Not a big deal, never mind.
I just had to try.. ;)
Check my free programs here..

Jerry
Posts: 834
Joined: 05 May 2010 15:48
Location: The UnUnited States of America

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by Jerry »

Actually, this works. Just add another operation for Go To (new tab). And you can modify or add to this similarly for new background tab, tab in other pane, etc.

Code: Select all

// This script pops up a menu of destinations and actions (Move, Copy or Go To),
// then performs the chosen operation for the chosen destination
// using selected items if relevant.
// [Created by XYplorer forum Jerry]

//==================================================================
// Define your preset destinations here:
    $destinations = <<<#---MENU_END
Downloads
Documents
Desktop
-
Windows System Folders 
  AppData (Roaming)|%appdata%
  AppData (Local)|%localappdata%
  Temp|%temp%
  Program Files (64bit)|%programfiles%
  Program Files (32bit)|%programfiles(x86)%
#---MENU_END;
//==================================================================

// Check for selected items
   $selcount = gettoken(<selitems |>, "count", "|");

// Ask for Action
    $action = popupmenu("Go To|Go To (new tab)|Copy|Move");
    if ($action == "") { end 1; } // user cancelled

    if (substr($action, 0, 5) == "Go To") {
	   $selcountDisplay = ""
    } else {
	   // Require selected items if necessary for the action
	   if ($selcount == 0) {
			msg "You must select one or more items for the chosen operation ($action).";
			end 1==1;
	   }
	   $selcountDisplay = " (" . $selcount . " items)"
	}
// Build menu of destination names, include the $action with item count as a disabled header
	$menu = recase($action, "upper") . $selcountDisplay . "|||4<crlf>-<crlf>" . $destinations;

// Show menu of destinations
    $choice = popupnested($menu, 6:=<crlf>, 7:="|");
    if ($choice == "") { end 1; } // user cancelled

    $dest = trim($choice);

    if ($action == "Go To") {
	   goto $dest;
	   end 1==1;
	} elseif ($action == "Go To (new tab)") {
       tab("new", $dest);
	   end 1==1;
    }

// Perform the operation on selected items
    if ($action == "Move") {
        moveto $dest, <get SelectedItemsPathNames |>;
    } elseif ($action == "Copy") {
        copyto $dest, <get SelectedItemsPathNames |>;
    }
Running on Windows 10 Pro 64-bit quad-core ASUS G752-VY notebook with 64 GB RAM, over 26 external USB3 drives attached via multiple powered hubs with letters and mount points, totaling 120+ TB.

noembryo
Posts: 178
Joined: 13 Apr 2022 21:40
Location: Windows 10 @100%
Contact:

Re: CommonPathsAndOperations.xys - Goto/Copy/Move to common destinations

Post by noembryo »

Nice :tup:
Check my free programs here..

Post Reply