How to copy/move a folder full of links to other folders and keep the links after the move/copy?

I have a problem.
Presently I have several folders that contain links to other folders.Example:


This folder (Community_full2) contains only links to other folders.
Now I want to move "Community_full2" to another place.
But presently, when doing so, the move/copy operation copies also all the linked data to the destination folder and as a consequence, my copied/moved "Community_full2" folder contains directly all the linked data (all these data have been copied inside the "Community_full2" and there no more links in the copied "Community_full2")

So, how to copy/move such a folder like "Community_full2" and keep all the links untouched inside this folder as they are at the origin?


If it's only a small number of folders, I would just create new links in the new location.

If you need to do it more often or for a lot of folders, I'd create a button or hotkey in Opus which runs robocopy.exe with the /SJ and /SL arguments (which make it copy junctions and links as junctions and links, rather than copy their contents):

Type: MS-DOS Batch

robocopy.exe {sourcepath$|noterm} {destpath$|noterm} /E /SJ /SL

That will replicate all the junctions in the source folder into the destination folder. (Nothing needs to be selected first.)

Thank you for the solution.
Could i add this as a command in the contextual menu?
What are the « noterm » options?
Could i make it work using the two panels of directory opus?
Is robocopy a standard tool of windows?

Yes, it will work in context menus.

Adding it to the file display background menu would make most sense, since it works on the current folder (not the selected or right-clicked folders or anything like that). You can edit that via Settings > Customize > Context Menus > Lister Context.

They prevent a \ being added to the end of folder paths. Search for "noterm" in the manual for full details.

That's what it already does. {sourcepath} is the source folder and {destpath} is the destination folder in a dual-pane window.

Yes, it should always be there (unless you go back to the Windows 95 era).


I set this in the context menu related to files and folders and it does not work. Nothing is copied.

But when I use robocopy using a command prompt under windows, it works ok, but I must run with administrative rights for it to work.

The command that works under windows is
« Robocopy source_dir dest_dir, /e /sl /sj »

What I have done in dopus:

In file types, all folders and files, I access the context menu tab, edit, add a new entry as « copy links » and as content I choose run an application
And then I add the above command line, but using sourcepath$ and destpath$ as folders, but nothing happens when executing the new entry of the context menu.

I tried:
{Sourcepath$} {destpath$} >> ko
{Sourcepath$|noterm} {destpath$|noterm} >> ko
{Allfilepath$} {destpath$} >> ko

So, what is going wrong here?



If it needs admin rights to work then you need to add @admin on a new line at the top of the command.

Thank you Leo, it works with @admin.

Hi again Leo,
I have nevertheless a problem. Using allfilepath$ selector of items to robocopy.

Suppose I have the folder "c:\origin" that contains folders "orig1" "orig2" "orig3" that contain links.
"orig2" contains links link1 link2 link3

I display "origin" folder as source in dopus.
I create a "dest" directory and set it as dest folder in dopus.

Now, I select "Orig2" and I want to copy it to "dest"

I use the command
robocopy.exe {allfilepath$|noterm} {destpath$|noterm} /E /SL /SJ

The result is that under "dest" directory, I have the content of "orig2", but not the folder "orig2"
I have link1 Link2 Link3 directly under folder "dest"

So source structure is like this

Dest structure after robocopy of orig2 using the above command

Dest structure I would like to be after robocopy of orig2

How to solve this?
If I use "sourcepath$" instead of "Allfilepath$", it works ok, but it copies all folders under "origin" and I do not want this.

That doesn't look right based on the Robocopy /? help text:

              Usage :: ROBOCOPY source destination [file [file]...] [options]

             source :: Source Directory (drive:\path or \\server\share\path).
        destination :: Destination Dir  (drive:\path or \\server\share\path).
               file :: File(s) to copy  (names/wildcards: default is "*.*").

I would have expected this to work, but it doesn't:

robocopy.exe {sourcepath$|noterm} {destpath$|noterm} {allfile$|noterm} /E /SL /SJ

That copies things that aren't even selected, so I'm guessing the File(s) to copy part really means files and not folders, or something. I'm not a Robocopy expert, though.

You can get what you want by running it once per selected item (which Opus will do for you automatically):

robocopy.exe {filepath$|noterm} {destpath$}{file$|noterm} /E /SL /SJ

The output in the command prompt will have a lot of extra noise, but it seems to get the job done, at least from a quick test.

Hi Leo,
I made it work using this command after selecting several folders inside sourcepath:

"robocopy.exe {sourcepath$}{file} {destpath$}{file} /E /SL /SJ"

And it works intended

1 Like