Move to .. , Copy to .. in Caja

@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:

#!/bin/bash
numberArgs=$#

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

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

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
fi

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.

2 Likes