diff options
author | vg@devys.org <vg@devys.org> | 2018-08-27 17:31:25 +0200 |
---|---|---|
committer | Cédric Picard <cpicard@purrfect.fr> | 2018-09-01 21:47:37 +0200 |
commit | a31ea7cfd15549d4e0a62c512c89d33463a9185b (patch) | |
tree | dd4adb648c770ec632827f0ec0653f40acafb690 | |
parent | e19fe8b4f41506e334c61f371be40b1f7ea65995 (diff) | |
download | bulkrename-a31ea7cfd15549d4e0a62c512c89d33463a9185b.tar.gz bulkrename-a31ea7cfd15549d4e0a62c512c89d33463a9185b.tar.bz2 bulkrename-a31ea7cfd15549d4e0a62c512c89d33463a9185b.zip |
-rwxr-xr-x | bulkrename | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -15,7 +15,8 @@ namebase="$(mktemp -d)/blkrn" echo '# Modify filenames without removing any line, quitting aborts' \ > "${namebase}.2" tee -- "${namebase}.1" >> "${namebase}.2" -exec </dev/tty >/dev/tty || { echo 'Interactive terminal needed' >&2 ; exit 1; } +exec </dev/tty >/dev/tty \ + || { echo 'Interactive terminal needed' >&2 ; exit 1; } "$EDITOR" "${namebase}.2" sed -i -- '1d' "${namebase}.2" @@ -25,12 +26,11 @@ if [ $(wc -l < "${namebase}.1") -ne $(wc -l < "${namebase}.2") ] ; then echo "Wrong number of lines" >&2 ; exit 1 fi -sed -i -- 's/\([\\"$`]\)/\\\1/g;' "${namebase}.1" "${namebase}.2" - (echo '# Please review/modify this script or empty it to do nothing' \ - ; comm -3 --output-delimiter="" "${namebase}.1" "${namebase}.2" \ - | tr -d '\0' \ - | sed 's/^.*$/"&"/' \ + ; while read -r l1 <&3 && read -r l2 <&4; do + [ "$l1" = "$l2" ] || printf "%s\n%s\n" "$l1" "$l2" + done 3<"${namebase}.1" 4<"${namebase}.2" \ + | sed 's/\([\\"$`]\)/\\\1/g;s/^.*$/"&"/' \ | xargs -d"\n" -L2 echo 'mv -i --') \ > "${namebase}.sh" |