conv1to2 now uses ncsv for formatting

This commit is contained in:
q
2014-11-23 17:12:48 +02:00
parent a5975888c9
commit 1f96c4a1f3

View File

@@ -6,6 +6,8 @@ then echo rename files in current folder replacing arg1 with arg2.
echo '-n for match non ascii, replace with arg2' echo '-n for match non ascii, replace with arg2'
exit exit
fi fi
POSTPROC="sed 's, , -> ,'"
which ncsv &>/dev/null && POSTPROC="ncsv -c"
c=0 c=0
if [ "$1" = "-n" ] if [ "$1" = "-n" ]
then for file in $( ls | grep -P "[\x80-\xFF]" ) then for file in $( ls | grep -P "[\x80-\xFF]" )
@@ -19,11 +21,12 @@ then for file in $( ls | grep -P "[\x80-\xFF]" )
done done
exit exit
fi fi
(
echo -e "Matching\tReplaced"
for file in $( ls | grep -- "$1" ) for file in $( ls | grep -- "$1" )
do echo "$file" '->' "$( echo $file | sed s/"$1"/"$2"/g )" do echo -e "$file"\\t"$( echo $file | sed s/"$1"/"$2"/g )"
c=$(( $c + 1 )) done ) | eval $POSTPROC | grep --color=always -E "$1|$"
done echo 'Sure?'
echo $c' matches. Sure?'
read i read i
for file in $( ls | grep -- "$1" ) for file in $( ls | grep -- "$1" )
do mv -iv -- "$file" "$( echo $file | sed s/"$1"/"$2"/g )" do mv -iv -- "$file" "$( echo $file | sed s/"$1"/"$2"/g )"