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

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

1 Answer 1

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 http://g-scripts.sourceforge.net/

You would like to see the File Management scripts at http://g-scripts.sourceforge.net/cat-filesysmgt.php

Here is what you need,

#!/bin/sh
# Author : Your Name <me@gmail.com>
# 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 http://blog.sriunplugged.com/shell-scripting/send-to-in-linux/

share|improve this answer
2  
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

 
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.