From 5e7ae40f950943f857b0a0a0b2114a7a76af83b2 Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Tue, 30 Sep 2014 22:30:48 +0300 Subject: [PATCH] match counter --- conv1to2 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/conv1to2 b/conv1to2 index 563e661..575d633 100755 --- a/conv1to2 +++ b/conv1to2 @@ -6,12 +6,13 @@ then echo rename files in current folder replacing arg1 with arg2. echo '-n for match non ascii, replace with arg2' exit fi - +c=0 if [ "$1" = "-n" ] then for file in $( ls | grep -P "[\x80-\xFF]" ) do echo "$file" '->' "$( echo $file | tr -d \\n\\r | tr -c [:print:] '\000' | sed s/'\x0'/"$2"/g )" + c=$(( $c + 1 )) done - echo 'sure?' + echo $c' matches. Sure?' read i for file in $( ls | grep -P "[\x80-\xFF]" ) do mv -iv -- "$file" "$( echo $file | tr -d \\n\\r | tr -c [:print:] '\000' | sed s/'\x0'/"$2"/g )" @@ -20,8 +21,9 @@ then for file in $( ls | grep -P "[\x80-\xFF]" ) fi for file in $( ls | grep -- "$1" ) do echo "$file" '->' "$( echo $file | sed s/"$1"/"$2"/g )" + c=$(( $c + 1 )) done -echo 'sure?' +echo $c' matches. Sure?' read i for file in $( ls | grep -- "$1" ) do mv -iv -- "$file" "$( echo $file | sed s/"$1"/"$2"/g )"