Caja-Action copy to bookmark folders

Hi, I’ve poked around a bit and found this topic and it’s good but not quite what I want and I haven’t any clue how to modify it.

From what I THINK i"m seeing here is the script opens a dialogue box allowing you to choose the destination. I want to be able to have specific coded locations to choose from rather than a dialogue box. Ideally those locations would be the caja “bookmarks” and auto update as I add and remove them but I’d be happy with adding them to the script file by hand.

So, to reiterate I’d like to right click on a file, multiple files, or a folder and use the context menu to select from a list of desinations rather than navigating to the actual loction.

right click [file] --> Scrips --> Movies
Music
Documents
Audio

I guess even having seperate scripts for each destination would work but how do I modify the code in the aforementioned thread to get rid of the dialogue and have it go automatically to s specific directory. My first intro to scripts just happened today when I realized I missed that option from other file managers I’ve used in the past and got tired of opening a new pane to use the “copy to --> other pane” function.

TIA and I realize this was a bit wordy but I know how short requests can be clear to the writer but not the audience.

Danneauxs

Hi @danneauxs,

I found this link:

http://thefrugalcomputerguy.com/linux/fromXPtoLinux/fromXPtoLinux8.php

which I took from this UM forum thread posted by @alpinejohn :

Thanks, I’ll watch the vids. Maybe there’s an options built into caja to do what I want and I just haven’t found in the last 2 years. If not, there is probably plenty of stuff to learn from them.

Thanks

See here:

Thanks Stevecook172001. I’ve read that one and used the code but it just opens a dialogue box that lets me hunt down the folder I want. I’m looking for just a list of specific destination directories. Did I miss something in that thread that did that?

Thanks

I have just had a bit of a play around with the script from that other thread and have found the following to work for pre-specified locations:

#!/bin/bash
numberArgs=$#

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

TARGETDIR=/home/stephen/Pictures

 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
fi

You just need to change the TARGETDIR to wherever you want it to be and then name the script appropriately, when you save it, to indicate the destination of the copy. Thus, the one above is for copying to the pictures folder. So, when I saved it, I have called it “copy-to-pictures-folder.sh” Set the file as executable and place it in your .config/caja/scripts folder.

You could create a number of these scripts, each for a different location and place them in your scripts folder. Then, they will appear as a list of locations to copy to when you right click your context-scripts menu

I should add, this script works for individual files, multiple files or folders

To make a move version, change cp to mv.

2 Likes

Awsome, I’ll give it a try tonight. That’s exactly what I wanted and how I thought it would work with seperate scripts.

Thanks!

You should add a relative path for target dir like TARGETDIR=~/Pictures . Becouse other users may have other username than stephen . " ~/ " is env. var that expands the users home folder .
It is also good for multy user PCs.

I have already indicated that the TARGETDIR should be amended to whatever or wherever the person wants it to be. By definition, that will necessarily involve changing the account name and I am pretty confident the person who I replied to is aware of this

1 Like

Works like a champ. Exactly what I needed. I’ve already spawned a dozen scripts which makes sorting all my files quick and easy. One of many methods to accomplish my goal and one I am personally happy with.

Thanks for the help.

Danneauxs

1 Like

What about move to script?
I can’t just change cp to mv the copy to script from this link: Move to .. , Copy to .. in Caja (It didn’t work)

Instead of I modified the “move to” script to be as follows to make it work: (Any hints?)

#!/bin/bash
numberArgs=$#

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

if [ “$?” -eq 1 ]; then
zenity --error --text=“Cancelled” --auto-close
exit 1
fi

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

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

if [ “$?” -eq 1 ]; then
zenity --error --text=“Cancelled!” --auto-close
exit 1
fi

Not everyone likes working with scripts.

Having just started working with Caja after two years of Nemo it is one feature I miss.

Have you tried installing nemo?

sudo apt-get install nemo

1 Like

Funnily enough I did just that, earlier.

Obviously great minds think alike. :grin:

For added spice the Ubuntu MATE 16.04 machine sits right next to an Ubuntu Unity 14.10 box, so that direct comparison was possible.

I was surprised to find that it didn’t work. :cry:

There is obviously more to this than just Caja and Nemo.

1 Like