Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Whenever you want to open a file with a program that's not in the right-click shortlist, you click 'use a custom command.' However, the way that's worded led me to believe that it may be possible to treat the file as if it were $@, command line input.

What I want to be able to do is add the custom command 'cp (clickedfile) /my/directory'...

However, the custom command 'cp $@ /my/directory' did not work.

share|improve this question
did you try $1 instead $@ ?? – Luciano Facchinelli Jan 23 '11 at 4:05
up vote 3 down vote accepted

Ideally you should create a Nautilus script to perform this task. A Nautilus script is a well-defined way to perform complex tasks in GNOME.

For more on Nautilus scripts with examples, see

You would like to see the File Management scripts at

Here is what you need,

# Author : Your Name <>
# Date : 01/01/2011
# depends: none
# version 0.1
# This script copies a file to a specific directory
# Copy this script in your ~/.gnome2/nautilus-scripts directory

cp $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS /home/myuser/mydirectory/
exit 0

The beauty with this is that you can select multiple files and it still works.

If you want something a bit more complex than that, see

share|improve this answer
That script will break on any files containing whitespace or other odd characters. One should use "$@", and quoted at that: cp "$@" /my/directory – geirha Jan 23 '11 at 12:03
i couldn't get that to work, geirha – ixtmixilix Oct 17 '11 at 21:06

Your Answer


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.