How can I initiate Nautilus file operations from the command line?
How can I start Nautilus's "File Operations" GUI from the command line?
My goal is to include this in a Nautilus script.
Solution 1:
The short answer is, you can't. Nautilus is not built to allow that sort of thing and you can go through the source code of nautilus and look at the file copy/move sections to see how it works.
Part of this lack of integration was the motivation behind the progress indicator design. It would replace the nautilus progress window and several other progress inconsistencies and allow multiple programs to show their progress to the user in the same way:
https://wiki.ubuntu.com/Ayatana/ProgressIndication
More work and advocacy for these new designs would help, allowing integration of all sorts of tools.
Solution 2:
From a discussion in irc://irc.gnome.org#nautilus, I can say that the current version of Nautilus do not expose methods for file operation on D-Bus, but version 3.0 will do, so the answer should be
you can't, now, but you will in the future
Solution 3:
Apparently this is now supported; at least the following seems to work under 12.04:
qdbus org.gnome.Nautilus /org/gnome/Nautilus org.gnome.Nautilus.FileOperations.CopyFile "file:///source/directory" "*" "file:///destination/directory" ""
where /source/directory
is the absolute path to your source directory, *
is the glob for file[s] to copy, /destination/directory
is your destination directory and the last ""
is for destination file name. Note that you need to have the last one there even if it's empty as in here, to fulfill the method signature. Also, if you specify a target name and have multiple source files, they'll all get copied to that one destination file, giving an overwrite prompt for each file after the first one (which may or may not be what you want).