Add to copy/move to menu

Is it possible to add custom locations to the copy/move to menus?

If so, how?

2 Likes

open up a blank pluma file and paste the following into it:

location=zenity --file-selection --directory --title="Select a directory"
for arg
do
if [ -e $location/$arg ];then
zenity --question --title="Conflict While Copying" --text="File "$location/$arg" already exists. Would you like to replace it?"
case "$?" in
1 ) exit 1 ;;
0 ) cp $arg $location ;;
esac
else
cp $arg $location
fi
done

Then save the file to /home/username/.config/caja/scripts as "copy-file-to-location.sh" (where "username", in the path, above, is your actual username). You will have to press CTRL/H during the save procedure in order to reveal the .config folder.

Then open uop caja and navigate to your home folder and press CTRL/H. This will display the hidden folders. One of which will be .config. Go into the .config/caja/scripts folder. In there you will see the new file you created. Right click the file and choose "properties".

Make sure to check the "execute file as program" checkbox. See below:

Close the dialog box.

now, if you go to any file on your system and right click, you will see a new context menu called "scripts". Inside there will be your newly created bash script. If you select it, it will allow to choose a location to copy the file to.

That's it.

P.S.

If the above does not work it will be because you have not got zenity installed. In which case, install it with:

sudo apt-get install zenity

thanks for this steve.

however it doesn’t seem to be working properly for me.

i’ve made script with your code.
i saved into proper directory
i made it executable
i already had zenity installed

i right-click on file or folder, and i see a new scripts submenu with copy-to-location.sh in it.
But nothing much happens when I click on it.

When right-clicking in caja, nothing happens when i select the script.
when right-clicking on file/folder on desktop, something only happens if there are no spaces in name of file/folder. It then tells me ‘conflict while copying - would you like to replace?’

Hi mickey. That’s a complete bafflement to me as I did it to test it before posting and it worked perfectly.

I’m just going to fully repeat the entire procedure now and record it and post it here as a video. I should have it up in the next ten minutes. Check out the video and see if you did everything exactly the same as me.

eyup mickey

as explained in vid, it’s this bloody site that is mangling the text.

So:

location=`zenity --file-selection --directory --title="Select a directory"`
for arg
do
if [ -e $location/$arg ];then
zenity --question --title="Conflict While Copying" --text="File "$location/$arg" already exists. Would you like to replace it?"
case "$?" in
1 ) exit 1 ;;
0 ) cp $arg $location ;;
esac
else
cp $arg $location
fi
done

use the text above to replace the existing text in your created file. In other words, open the file, delete the text, paste the new text and save.

Sorted!

Hang on, the bugger is still not working!

Now that has got me completely stumped!

Right, I’ll drop a copy of the actual file in my google drive and make a link here for you to download it and place in your scripts folder.

That one HAS to work!

https://drive.google.com/file/d/0B6bBLy1wZYSeUXhUSlE4TEFXeGM/view?usp=sharing

right then,

Download the copy I left on the google drive link, above.

Copy it form downloads folder to caja scripts folder.

Right click the file and check the “execute file as program” check-box in the permissions tab.

It should then work

I have just downloaded it myself and can confirm it works if you do what I said above.

nice one steve - that’s working now!

lesson learned: always use the </> to format program code! the absence of a ` or two makes a huge difference!

it’s very handy that the ‘select a directory’ window shows fave folders at the bottom.

it would be great if you could actually add locations to the existing ‘copy/move to’ sub-menus.

thanks again - much appreciated mate!

edit

i’ve made a small change to script so it works with file/folder names that include spaces.

location=`zenity --file-selection --directory --title="Select a directory"`
for arg
   do
     if [ -e "$location"/"$arg" ];then
       zenity --question --title="Conflict While Copying" --text="File "$location/$arg" already exists. Would you like to replace it?"
     case "$?" in
       1 ) exit 1 ;;
       0 ) cp "$arg" "$location" ;;
     esac
     else
       cp "$arg" "$location"
     fi
   done

all i did was to wrap the $arg and $location variable names in quotes.

edit 2

made another script replacing ‘cp’ commands with ‘mv’ to move rather than copy file.

1 Like

You’re welcome Mickey. Glad I could help

By the way like the “move” mod. I’ll be using that one!

1 Like