From 1f96c4a1f30a47cd682b2eb18da9a8ee27af4d0f Mon Sep 17 00:00:00 2001 From: q Date: Sun, 23 Nov 2014 17:12:48 +0200 Subject: [PATCH] conv1to2 now uses ncsv for formatting --- conv1to2 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/conv1to2 b/conv1to2 index 575d633..6bb406d 100755 --- a/conv1to2 +++ b/conv1to2 @@ -6,6 +6,8 @@ then echo rename files in current folder replacing arg1 with arg2. echo '-n for match non ascii, replace with arg2' exit fi +POSTPROC="sed 's, , -> ,'" +which ncsv &>/dev/null && POSTPROC="ncsv -c" c=0 if [ "$1" = "-n" ] then for file in $( ls | grep -P "[\x80-\xFF]" ) @@ -19,11 +21,12 @@ then for file in $( ls | grep -P "[\x80-\xFF]" ) done exit fi +( +echo -e "Matching\tReplaced" for file in $( ls | grep -- "$1" ) -do echo "$file" '->' "$( echo $file | sed s/"$1"/"$2"/g )" - c=$(( $c + 1 )) -done -echo $c' matches. Sure?' +do echo -e "$file"\\t"$( echo $file | sed s/"$1"/"$2"/g )" +done ) | eval $POSTPROC | grep --color=always -E "$1|$" +echo 'Sure?' read i for file in $( ls | grep -- "$1" ) do mv -iv -- "$file" "$( echo $file | sed s/"$1"/"$2"/g )"