Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- contract=Договор.docx
- data=Контрагенты.csv
- out="В бухгалтерию"
- mkdir "$out"
- 2>/dev/null rm "$out"/*
- for i in $(seq 1 $(wc -l $data | cut -f 1 -d ' ')); do
- dir=$(mktemp -d)
- pwd=$(pwd)
- unzip -d $dir $contract > /dev/null
- REPLACE00=$(head -n $i $data | tail -n 1 | cut -f 1 -d ',')
- REPLACE01=$(head -n $i $data | tail -n 1 | cut -f 2 -d ',')
- REPLACE02=$(head -n $i $data | tail -n 1 | cut -f 3 -d ',')
- REPLACE03=$(head -n $i $data | tail -n 1 | cut -f 4 -d ',')
- cat $dir/word/document.xml | \
- sed -r "s/REPLACE00/$REPLACE00/g" | \
- sed -r "s/REPLACE01/$REPLACE01/g" | \
- sed -r "s/REPLACE02/$REPLACE02/g" | \
- sed -r "s/REPLACE03/$REPLACE03/g" \
- > $dir/word/document.xml~
- mv $dir/word/document.xml~ $dir/word/document.xml
- cd $dir
- zip -r "$pwd/$out/Договор_$REPLACE00.docx" ./ > /dev/null
- cd $pwd
- rm -r $dir
- echo "Договор №$REPLACE00: $REPLACE01 покупает $REPLACE02 за $REPLACE03 - готово."
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement