diff options
author | VG <vg@devys.org> | 2016-01-25 20:48:14 +0100 |
---|---|---|
committer | VG <vg@devys.org> | 2016-01-25 20:48:14 +0100 |
commit | 552252a172eebe758f2c87131c4da33c6a3cc4d5 (patch) | |
tree | d676340f55036562f9e71c36bdaca2e58db578da | |
parent | ac5deefcfba8a5e29634af50cd43941d81b051c5 (diff) | |
download | bulkrename-552252a172eebe758f2c87131c4da33c6a3cc4d5.tar.gz bulkrename-552252a172eebe758f2c87131c4da33c6a3cc4d5.tar.bz2 bulkrename-552252a172eebe758f2c87131c4da33c6a3cc4d5.zip |
Optimize renaming process from a loop to pipes
-rwxr-xr-x | bulkrename | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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" |