Command to copy all files inside a selected folder into a destination folder

I'm looking for a way to copy all files in a folder I'm selecting in one pane inside a destination folder in the other pane without opening either. Ideally I'd click on a 1st folder in one pane, click on another in a 2nd pane and press a hotkey to transfer all contents of the 1st folder into the 2nd.

I've tried a number of things pieced together from similar sounding functions on here, but haven't found anything that's worked. Can anyone help?

Thanks!

@disablenosel:mindirs=1,maxdirs=1
@enableif:=is_dual()
Copy "{f!}/*" TO "{fd!}/" 

Note:

  • This button (on which you'll have to bind a hotkey) is only doing minimal failsafe tests (e.g. the fact that destination selection is a folder is not tested, if no destination folder is selected, files will get copied to the destination folder instead, ...)
  • This button is using standard source/destination behavior, meaning by default source is the pane that has focus, not necessarily the left/top pane

Thank you! Works perfectly.

There are two similar functions I'm trying to get working. I tried editing the code you wrote here to fit them but I'm having no luck again. Would you know how to do these functions:

  • Move all files in selected folder into destination folder (not a selected folder in the destination folder, just the destination folder itself)
  • Move selected files into a selected folder in destination pane.

For the first one, you need to modify the code in my previous answer and change the Copy line to:

Copy {f!}/* TO {d!}/

For a better understanding of all this, you can refer to External control codes [Directory Opus Manual], and more specifically to Codes for passing filenames [Directory Opus Manual] and Codes for passing paths [Directory Opus Manual]. Of course Copy [Directory Opus Manual] is also your friend.

The second one is in the default operations toolbar on the "Move" menu-button.
Note that it will operate on any selected object (files and folders). if you want it to just move files but ignore folders, you need to modify it (or duplicate it and modify the dupe) and add @filesonly before the Copy Move instruction (on a line of its own).

Thanks again! The first item works perfectly too. I'll re-explain the 2nd one I'm after, I don't think any default move operation does this so I want to make sure:

  • A selected file in pane 1
  • A selected folder in pane 2
  • The function should put the selected file in pane 1 inside the selected folder in the other pane

Reading the provided links is not forbidden :slight_smile:

@enableif:=is_dual()
Copy {F!} TO "{fd!}/"

If you're in the button editing dialog and click on the "Arguments" menu when you're editing the Copy line, it provides you the list of available arguments for that command. At the very bottom, you'll find the codes for passing filenames and filepaths.

EDIT: Above code is for copying files/folders, if you want to move them:

@enableif:=is_dual()
Copy MOVE {F!} TO "{fd}" 

Thanks again! Can be hard to wrap my head around syntax, the demonstration helps a lot.

I don't understand why, but the command

@enableif:=is_dual()

doesn't work for me.
I looked in the manual and the evaluator syntax seems correct.
To get it to work, I replaced it with

@enableif:Set DUAL=toggle

,but it's strange that it doesn't work. Maybe someone knows why.

is_dual is a variable, not a function. Remove the () and it should work.

I tried as you suggested but it doesn't work
I used this.

@enableif:=is_dual
Copy "{filepath$}" TO "{filepathdest$}"

What do you mean by "doesn't work" ?
What are you expecting to happen?
What does happen?

Sorry I was the one misleading with is_dual() (even if, FWIW, in that very context, both are working exactly the same here).

I've tried this, and this is working as expected here.

To be clear:

  • @enablelf:=is_dual : The button is enabled only in a dual lister.
  • Copy "{filepath$}" TO "{filepathdest$}" : since you're using the $ ending versions of filepath and filepathdest (also called the "need" forms) , the Copy will only do something if you both have:
    • File(s) and/or folder(s) selected in whatever pane is the source when you click the button (at least one item),
    • At least one folder selected in whatever pane is the destination when you click your button.

Otherwise, nothing will happen, since it fails to fulfill the requirements for the need form.

Note that if you have only a file selected in destination pane, you'll get an error (my guess is that the Copy command checks for a folder in the destination pane with the provided name, which does no exists).

I expect it to be selectable. Instead, it remains inactive even when I select a source and destination folder.
As I wrote above, however, after testing, I found that if I place it in a menu, it never activates. However, if I place it as the main button in the toolbar, it behaves correctly.

Something's wrong, I think.
If I put the same button in the toolbar, it works, but if I move it to a menu (like I had), it doesn't work anymore.
You could try moving it.
Thanks

There are two different things at work here:

  • @enableif: lets you decide wether the button is active or not. Only one condition here : is_dual. That means that the fact that folders/files are selected or not will not interfere with the button state.
  • $ at the end of the codes used to pass filenames/filepaths: this will interfere with the fact that the action is taken or not, but this does not disable the button.

And yes, I have the same behaviour as you do: is_dual works fine when the button is in a toolbar, but as soon as you put it into a menu of a toolbar, it's always disabled.
At first sight, I would qualify this as a bug, but I let @Jon rule on this one since there might be some reasonning behind.

I completely agree with what you're saying.
It was implied that if I can select the source and destination, I'm in dual mode. It's worth clarifying, though....
...and thanks for the confirmation