-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_results_tex.sh
More file actions
executable file
·68 lines (60 loc) · 2.05 KB
/
Copy pathprocess_results_tex.sh
File metadata and controls
executable file
·68 lines (60 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# Enable error handling and detailed logging
set +e
set +x
# Function to log messages with timestamp
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
}
# Function to log errors
log_error() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1" >&2
}
# Process all markdown files in benchmark results
log "Starting processing of benchmark result files..."
# Initialize counters
processed_count=0
error_count=0
# Process all TeX files (table exports) in benchmark results
log "Starting processing of TeX table export files..."
# Use find for recursive search of TeX files
while IFS= read -r -d '' tex_file; do
if [ -f "$tex_file" ]; then
log "Processing TeX file: $tex_file"
tex_dir=$(dirname "$tex_file")
base_name=$(basename "$tex_file" .tex)
output_file="${tex_dir}/${base_name}.pdf"
# Skip if output file already exists
if [ -f "$output_file" ]; then
log "Skipping $tex_file - output file $output_file already exists"
continue
fi
log "Converting $tex_file to $output_file"
# Use pdflatex to compile TeX to PDF
# Run in the directory containing the TeX file to handle relative paths
pushd "$tex_dir"
pdflatex -interaction=nonstopmode "${base_name}.tex" > /dev/null 2>&1 && pdflatex -interaction=nonstopmode "${base_name}.tex" > /dev/null 2>&1
if [ $? -eq 0 ]; then
log "Successfully converted: $tex_file -> $output_file"
# Clean up auxiliary files created by pdflatex
rm -f "${base_name}.aux" "${base_name}.log"
((processed_count++))
else
log_error "Failed to convert: $tex_file"
((error_count++))
fi
popd
else
log "Skipping non-file or non-existent: $tex_file"
fi
done < <(find results -name "*.tex" -type f -print0 2>/dev/null)
# Final summary
log "Processing complete!"
log "Files processed successfully: $processed_count"
log "Files with errors: $error_count"
if [ $error_count -gt 0 ]; then
log_error "Some files failed to process. Check the logs above for details."
exit 1
else
log "All files processed successfully!"
fi