Initial commit of converter
This commit is contained in:
+17
-2
@@ -2,6 +2,8 @@
|
||||
# Batch runner para apply_template.py
|
||||
# Procesa los documentos en /tmp/batch_t*.txt
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
TEMPLATE="/mnt/c/Users/javie/Documents/R360MX/cloud/01. Info General/02. Standards/03. Templates/TPL01-Reports.docx"
|
||||
DIR="/home/javi/.openclaw/workspace/r360mx-docs-converter"
|
||||
LOGFILE="/tmp/r360mx_batch_$(date +%Y%m%d_%H%M%S).log"
|
||||
@@ -13,6 +15,18 @@ echo "" | tee -a "$LOGFILE"
|
||||
TOTAL=0
|
||||
OK=0
|
||||
FAIL=0
|
||||
TOTAL_BASE=0
|
||||
|
||||
# Primero contar docs totales
|
||||
for TANDA in /tmp/batch_t1.txt /tmp/batch_t2.txt /tmp/batch_t3.txt /tmp/batch_t4.txt; do
|
||||
if [ -f "$TANDA" ]; then
|
||||
COUNT=$(wc -l < "$TANDA")
|
||||
TOTAL_BASE=$((TOTAL_BASE + COUNT))
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Total documentos: $TOTAL_BASE" | tee -a "$LOGFILE"
|
||||
echo "" | tee -a "$LOGFILE"
|
||||
|
||||
for TANDA in /tmp/batch_t1.txt /tmp/batch_t2.txt /tmp/batch_t3.txt /tmp/batch_t4.txt; do
|
||||
if [ ! -f "$TANDA" ]; then
|
||||
@@ -20,13 +34,14 @@ for TANDA in /tmp/batch_t1.txt /tmp/batch_t2.txt /tmp/batch_t3.txt /tmp/batch_t4
|
||||
fi
|
||||
|
||||
NUM=$(wc -l < "$TANDA")
|
||||
echo "--- Tanda: $(basename $TANDA) ($NUM docs) ---" | tee -a "$LOGFILE"
|
||||
echo "--- Tanda: $(basename "$TANDA") ($NUM docs) ---" | tee -a "$LOGFILE"
|
||||
|
||||
while IFS= read -r DOC; do
|
||||
TOTAL=$((TOTAL + 1))
|
||||
echo -n "[$TOTAL/$TOTAL_BASE] $(basename "$DOC")... " | tee -a "$LOGFILE"
|
||||
|
||||
if cd "$DIR" && python3 apply_template.py "$DOC" "$TEMPLATE" >> "$LOGFILE" 2>&1; then
|
||||
# Ejecutar en subshell para no alterar el directorio actual
|
||||
if ( cd "$DIR" && python3 apply_template.py "$DOC" "$TEMPLATE" ) >> "$LOGFILE" 2>&1; then
|
||||
echo "✅" | tee -a "$LOGFILE"
|
||||
OK=$((OK + 1))
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user