Ask to replace duplicated files #1795
-
Is there a way to make |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I don't believe that there is a way without reconfiguring the paste command, however, you're more than welcome to write your own behavior for the paste command inside your lfrc file. |
Beta Was this translation helpful? Give feedback.
-
I took your command and changed it a bit. It does not work exactly like default because I have different cmd paste %{{
load=$(cat ~/.local/share/lf/files)
mode=$(echo "$load" | sed -n '1p')
list=$(echo "$load" | sed '1d')
for path in $list; do
file_name=$(basename $path)
new_path="$PWD/$file_name"
if [ -f "$new_path" ]; then
echo "Duplicated file name found $file_name. What to do? [k]eep old, [r]eplace with new or [p]reserve both "
read ans
if [ $ans = "k" ]; then
continue
elif [ $ans = "r" ]; then
echo "replacing $new_path with $path"
elif [ $ans = "p" ]; then
[[ "$file_name" == .* ]] && { dot="."; file_name="${file_name#.}"; }
name="${file_name%%.*}"
ext="${file_name#"$name"}"
i="${name##*[!0-9]}"
[ -z "$i" ] && i=1 || name="${name%%$i*}"
while [ -e "$PWD/$dot$name.$i$ext" ]; do
((i++))
done
new_path="$PWD/$dot$name.$i$ext"
else
notify-send "Unrecognized input"
fi
fi
if [ $mode = 'copy' ]; then
cp -R "$path" "$new_path"
elif [ $mode = 'move' ]; then
mv "$path" "$new_path"
fi
done
lf -remote "send $id clear"
}} |
Beta Was this translation helpful? Give feedback.
I took your command and changed it a bit. It does not work exactly like default because I have different
dupfilefmt
preferences, but you might be able to tweak that.