Move to .. , Copy to .. in Caja

I want when I right click a file to choose copy to and lets me choose where from a dialogue window . That is what i wanan do . Is it possible with caja-actions ? If so how ? Or maybe a script of some sort ?

1 Like

Just to make sure what you’re asking is clear, you want to right-click, select Copy To, and have it open a dialogue where you can type in the destination address?

Yep . Just like that оr like this

That would be easy using Caja-Actions and a script that used Zenity for input. I’ll have a go at creating it!

Okay after a couple of minutes playing around, I’ve done a proof of concept for creating a simple Copy to Caja-Action. I’ve deliberately kept it simple to and encourage you to tailor it to your needs.

The script is very simple:

OUTPUT=$(zenity --file-selection --directory --title="Choose your destination")
TARGETDIR=$(awk -F, '{print $1}' <<<$OUTPUT)
cp "$1" "$TARGETDIR/"

To create the Caja-Action:

  1. Save the script file as /home/username/bin/ and make it executable.
  2. Open the Caja-Actions Configuration Tool
  3. Create a new action
  4. Under the Action tab, give your action a Context label i.e. ‘Copy to…’
  5. Under the Command tab, enter the path (i.e. /home/username/bin/ to your script and enter %f in the Parameters field

To use the action:

  1. Right-click the file you want to copy and select Caja-Actions actions -> Copy to
  2. In the popup window, select the directory you wish to copy the file to and click OK
  3. The file will be copied

Customisation and refinement

This is a barebone proof-of-concept only. Feel free to edit the script to suit your needs, for example, copying multiple files, creating a Move to version, checking if a file already exists in the target directory etc…


I started writing a similar script yesterday but fell asleep before I could actually test it :smiley:
Creating a ‘Move to’ version is as simple as replacing the cp with mv.

Another suggestion would be to include the -r argument (recursively copy) with the copy command so that the folders can also be copied.


Tnx men . It worked perfect . And even better with the -r param becouse can copy folders to . Withought the -r param it could not copy folders .

1 Like

You’re welcome, mate. As noted, you are free to use what I did as a base to roll your own solution @rohithmadhavan’s suggestion was a great addition, case in point.

Glad to have helped :slight_smile:


@CGB is there a way to add a progress dialogue ?

Yes, there is. Zenity has a progress bar widget you can use.

I’ve just woken up, will post an example when I get into work.

1 Like

Ok @IvCHo, I’m in the office now!

Simplest way to add a progress bar is with another Zenity widget. Here’s the code:

echo "10" ; sleep 1
cp -r "$1" "$TARGETDIR/" ; sleep 1
echo "100" ; sleep 1

) |

zenity --progress \
      --title="Copy to" \
      --text="Copying..." \

Replace your cp ling in the original script with the above and you’ll get a basic progress bar. Note that I’ve included the -r switch as per @rohithmadhavan to allow for recursiving copying of folders.

Note that the widget works by letting you specify the steps so it’s not a true progress bar as such. You can probably write a more complicated recursive cp statement inside a loop that updates divides the number of files you are copying by 100 and update the progress bar accordingly when each file is copied across.

There may be some way of using Caja’s native progress bar but I haven’t looked into that.

1 Like

@IvCHo, I was intrigued by my own suggestion so have come up with a working solution that pipes the output of a loop to Zenity.

I’ve adapted it from here, (after correcting a couple of bugs and modifying it to work with Caja-Action’s quirky handling of arguements).

Here’s the complete script:


OUTPUT=$(zenity --file-selection --directory --title="Choose your target directory")

if [ "$?" -eq 1 ]; then
    zenity --error --text="Cancelled"
    exit 1

TARGETDIR=$(awk -F, '{print $1}' <<<$OUTPUT)

 for (( i=1; i<=$numberArgs; i++ )); do
    echo "# ${1##*/}"
    cp -r "${1}" "$TARGETDIR/"
    echo "$(( (i * 100)/$numberArgs ))"
    sleep 0.5 
    shift 1
done | zenity --progress --title="Copy files to $TARGETDIR" --percentage=0

if [ "$?" -eq 1 ]; then
    zenity --error --text="Cancelled!"
    exit 1

This will work with folders. To make it work with multiple selections of files/folders, in the Caja-Actions Config tool, change the parameter from %f to %F.

To make a move version, change cp to mv.


Tnx man i appreciate it . I also have added --auto-close zenity parameter to your script . I hope you do not mind . If so i will delete it .

Of course I don’t mind! It was written to be shared and improved upon. Glad it was of use to you.


just changing cp to mv doesn’t works to me, instead of I modified a line of the script as follows: (please suggest!)

in copy to:
cp -r “${1}” “$TARGETDIR/”

to be

in move to:
cp -r “${1}” “$TARGETDIR/”
rm -r “${1}”

Do you replace “cp” with “mv” only or do you replace “cp -r” with “mv” . Becouse if you replace only “cp” with “mv” will trow a error that “-r” is not a known argument .

The first one, I think I should follow the second one. Thanks a lot! :+1: