From 552252a172eebe758f2c87131c4da33c6a3cc4d5 Mon Sep 17 00:00:00 2001 From: VG Date: Mon, 25 Jan 2016 20:48:14 +0100 Subject: Optimize renaming process from a loop to pipes --- bulkrename | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bulkrename b/bulkrename index 3df3b4b..88cb363 100755 --- a/bulkrename +++ b/bulkrename @@ -27,13 +27,13 @@ fi sed -i -- 's/\([\\"$`]\)/\\\1/g;' "${namebase}.1" "${namebase}.2" -paste -d "\n" "${namebase}.1" "${namebase}.2" | while read -r input ; do - read -r output +(echo '# Please review/modify this script or empty it to do nothing' \ + ; paste -d "\n" -- "${namebase}.1" "${namebase}.2" \ + | uniq -c \ + | sed -n 's/^ *1 \(.*\)$/"\1"/p' \ + | xargs -d"\n" -L2 echo 'mv -i --') \ + > "${namebase}.sh" - if [ "$input" != "$output" ] ; then - echo "mv -- '$input' '$output'" - fi -done > "${namebase}.sh" if [ "$(stat --printf="%s" "${namebase}.sh")" -ne 0 ] ; then "$EDITOR" "${namebase}.sh" -- cgit v1.2.3