Skip to content

Ask to replace duplicated files #1795

Answered by DusanLesan
omnigenous asked this question in Q&A
Discussion options

You must be logged in to vote

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.

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" == .* ]] &&

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@omnigenous
Comment options

@omnigenous
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by omnigenous
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants