I cannot find a way to initiate Thunar's file copy or move operations from the command line. This would be a very useful tool for Custom actions and Send to menu entries, even if limited to daemon mode.
Forgive me the short description, but there's really nothing more to say. I hope I haven't missed an already-present functionality that would allow me to do this.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
Currently thunar does not provide CLI arguments for copy / move. (Actually no file manager I checked does so)
I dont think it would be a good idea to add that feature.
Actually what exactly is your concrete use-case for it ?
Next willl be trash, delete, rename and 'open properties dialog' via CLI ... I am not so sure that I want all the extra-code if the only purpose is an edge-case.
An use case for this is a Copy to Desktop or Move to Desktop or any similar operation in the Send To menu or a Custom action. Currently it can be done with cp, mv and StartupNotify=true in the .desktop file to indicate operation with a loading mouse cursor, but it's not an optimal solution for an arbitrary long operation.
Trash, Delete, Rename and Properties already have a one-step way to be accessed from the GUI for an arbitrary selection of files. Rename and Properties even have their multi-file GUI dialogs so there is not much to script anyway.
While I would find all of them a cool addition to Thunar CLI, I can also explain the difference you are asking me about. It's different with Copy and Move because they require multiple steps including even changing the directory (copy/move, relocate, paste). Therefore it's more important for Copy and Move to be scriptable for quick operations than for the other mentioned ones.
Another use-case is simply copying and moving large files where a progress bar and a GUI indication is desired, even though the operation was started from CLI. I miss this sometimes when I use a drop-down terminal concurrently with Thunar for file-management operations.
CLI invocation of GUI copy/move operations seems like an useful feature so I'm actually surprised to find out that it's not more widespread. But in this case it would also be even cooler for Thunar to have it.
Ok, fine for me to indroduce CLI support for copy/move. Though please keep it simple --> single source, single target. I would not want to have that much extra-code for it.
I dont have time to work on it, though a MR would be welcome
Maybe it's not best described how to use it.
With gdbus it's similar.
List interfaces with: gdbus introspect --session --dest org.xfce.Thunar --object-path /org/xfce/FileManager
Then select one of the methods and call something like: gdbus call --session --dest org.xfce.Thunar --object-path /org/xfce/FileManager --method org.xfce.FileManager.CopyTo "working dir" "['file1', 'file2']" "['targetfile1', 'targetfile2']" ":0.0" ""
Arguments are:
s - string "String1"
as - array of strings in format "['String1', 'String2']"
b - boolean "true" "false"
a{sv} - arguments "{'String': <'variant_value'>, 'String2': <'variant_value'>}"
Thanks alot for the hint, I completely forgot that we offer a dbus service for it. So, yea, than we dont need additional CLI arguemtns for copy/move .. closing.
I've successfully implemented the Copy to Desktop and Move to Desktop.desktop entries for the Send To menu from @lastonestanding's solution and @misko_2083's kind explanation. The solution is as follows:
The file passes desktop-file-validate, but Exec needs quite a bit of quoting/escaping and a sh-wrap. The command could be simpler if wrapped in a script, but I was aiming for a one-file solution.
The first argument to D-Bus functions is the working directory. Since the absolute paths are used, it was set to /tmp for additional safety in case something goes wrong and a rogue operation is performed in the WD. Probably there is a better option. If the argument is empty, it defaults to home folder.
While it is possible to initiate Thunar's copy/move operations from CLI the actual commands require input reparsing, are long and require additional input as well. Also an additional logic between Copy/CopyInto and Move/MoveInto functions is needed somewhere. The solution isn't practical enough to solve use cases such as this previously-mentioned one:
Another use-case is simply copying and moving large files where a progress bar and a GUI indication is desired, even though the operation was started from CLI.
So I believe there is still some need for a thunar --cp and thunar --mv commands mimicking the original ones. It would also thoroughly simplify any Custom action/Send to implementations. I'd like to reopen this if we all agree.
So I believe there is still some need for a thunar --cp and thunar --mv commands mimicking the original ones. It would also thoroughly simplify any Custom action/Send to implementations. I'd like to reopen this if we all agree.
I disagree. Using thunar for CLI-copy imo is an exotic edge-case.. I dont want to take effort and add extra-code to make exotic edge cases "easy to use". If a more simple CLI command is needed, why not just using the dbus call in a self made script ?
If you have some uca (script based or single line) using the dbus call for copy/move which works with spaces in the path and multi-select, feel free to share, so it can be added to https://docs.xfce.org/xfce/thunar/custom-actions
Thanks for the suggestion, but GIO wouldn't perform the operation through a Thunar copy/move dialog, which is the original issue.
There is a solution, described in posts above. The only remaining question is whether Thunar should provide more user-friendly CLI commands/options for this. I still think it would be a very useful feature to have. There are some advantages to performing copy and move operations from CLI and some from GUI. Commands that could be easily remembered would be a cool (and apparently even an unique) feature.
@alexxcons Yes, you can use a self-made script, but the remaining question with the issue is that if might not only be an exotic edge case after all. Since you closed it expectedly not much people joined the conversation, but I still think I'd deserve a fair discussion.
The .desktop file in my solution is a working Send to menu implementation of a copy operation that can be added as an example in the Wiki. As far as I've tested it multi-selection and spaces in the path work and as mentioned the file passes desktop-file-validate. The "code" for move operation is the same, except for the three instances of "copy".
Thanks for the discussion. I'll have to try the .desktop file shown above, because might be exactly what I want.
Here's my use case. I have a laptop. I download podcasts using Rhythmbox and then copy them to a music player when it's plugged into the USB port. Then I delete the podcasts in Rhythmbox, which also deletes them from the laptop. I do this every day.
The laptop's touch pad makes drag-and-drop annoying, so I wanted to select the directories, right click, and use a "Send To" option. I tried creating a .desktop with cp, but this has two problems. First, there's no UI feedback to know when the copy is over and therefore is safe to delete the files in Rhythmbox. Second, one of the podcasts has a colon in the name (a news podcast at "6:00 PM"). Since the music player's storage is formatted as FAT, I can't simply cp --recursive the directory because FAT doesn't allow colons in file names. Thunar recently started replacing the colon with an underscore, which is great for me. So Thunar does both of these things better than cp for my use case.