Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

In Windows Explorer (and other file managers) if you drag a file onto a script/executable, then it runs the script/executable with that file as the first argument.

Is it possible to get a similar behaviour in Nautilus? (Would I have to use .desktop files / launchers?)

How about other linux file managers?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You need a .desktop file with EXEC= entry.

See related feature request on launchpad and bugzilla.

share|improve this answer
    
Thanks for that. I googled extensively on this, and somehow missed these (really old!) feature requests. Of course, for a .desktop file you can't use relative paths, but at least I can now drag-and-drop to execute my python script. –  Simon Jul 13 '11 at 0:26
    
@Simon: you're welcome! :) –  Vanni Totaro Jul 13 '11 at 14:13
    
I have the same problem, but I can't figure out your answer. Could you give more details (say, a sample .desktop name, where to store it, what name shall it have). Or give a link on relevant pages ? (the links given didn't help me). –  kebs Dec 22 '13 at 21:42
    
@kebs my answer was from 2011 (i just edited it to remove a dead link pointing to Ubuntu Brainstorm that is no more). I just tried the .desktop solution again under Ubuntu 13.10 and it seems to not work anymore, maybe because the handling of drop-a-file-over-another-file has been removed from Nautilus. Not a big surprise, because of the major changes to Nautilus in Gnome 3.x ( see en.wikipedia.org/wiki/Nautilus_(file_manager)#History ) –  Vanni Totaro Dec 23 '13 at 22:52
    
Thanks anyway, I'm running 12.04 for the LTS advantage, but this doesn't help. I'll probably post a question about this. Already 4 years as a happy linux user, but this is a major feature I miss from those Windows days... I find this so convenient, I can't figure out why it is so complicated to implement on gnome desktop. –  kebs Dec 24 '13 at 16:28

As of now with Ubuntu 14.04, the method of creating a .desktop file works again. For example:

[Desktop Entry]
Type=Application
Terminal=false
Name[en_EN]=all2pdf
Exec=/bin/bash -c "IFS=$'\n'; args=(`( for f in %U; do echo $f; done ) | sort`); dir=(`dirname $args`); convert ${args[@]} $dir/convert.pdf "

Putting this code in a file "all2pdf.desktop" and making this file executable by

chmod u+x all2pdf.desktop

allows to drag some files on the icon named "all2pdf" and converting them into one single PDF file using "convert".

The example command is lengthy, but is also contains a remedy for the list of files always being in reverse order (regardless of the selection order of the files that are dragged).

I have just used the above method (i.e. the file) to create a number of PDF files with few pages each from a bigger set of single pictures that I created using "Scan Tailor". It worked just fine and because comments on the above answer do imply that creating a .desktop file might not work anymore I would like to share the above example.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.