You are not logged in.

#1 2022-12-01 08:49:31

pepper
Member
Registered: 2017-12-09
Posts: 116

thunar xfce custom action: bash script to move content of a folder

Hello, I use a script in thunar to move the content of a folder to the parent directory and remove the folder:

find %f -maxdepth 1 -type d \( ! -name . \) -exec bash -c "mv -v '{}'/* . && rmdir '{}'" \;

the problem is that when there are folders with characters that needs an excape like apostrophes, the action is not executed, how could I fix the script to handle also these cases?

Offline

#2 2022-12-01 10:55:57

lambdarch
Member
Registered: 2021-01-10
Posts: 67

Re: thunar xfce custom action: bash script to move content of a folder

You could reverse the quotes (single <-> double), but then you'll have a problem with double quotes in the directory name.
So better to do this:

find %f -mindepth 1 -maxdepth 1 -type d -exec bash -c 'mv -v "$1"/* . && rmdir "$1"' _ {} \;

I also used -mindepth instead of filtering on directory names.

Offline

Board footer

Powered by FluxBB