-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathsync-output.sh
More file actions
49 lines (42 loc) · 1.22 KB
/
Copy pathsync-output.sh
File metadata and controls
49 lines (42 loc) · 1.22 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
#!/bin/bash
# Trae Local API - Output Sync Tool for Linux/Mac
# Usage: ./sync-output.sh
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
SOURCE_DIR="$SCRIPT_DIR/output"
DEST_DIR="${WORKSPACE_DIR:-$HOME/trae-workspace}"
if [ ! -d "$DEST_DIR" ]; then
echo "Creating destination directory: $DEST_DIR"
mkdir -p "$DEST_DIR"
fi
echo "============================================"
echo " Trae Local API - Output Sync Tool"
echo "============================================"
echo ""
echo "Source: $SOURCE_DIR"
echo "Dest: $DEST_DIR"
echo ""
count=0
skipped=0
while IFS= read -r -d '' file; do
rel="${file#$SOURCE_DIR/}"
dest="$DEST_DIR/$rel"
dest_dir=$(dirname "$dest")
if [ -f "$dest" ]; then
echo "[SKIP] $rel - already exists"
((skipped++))
else
mkdir -p "$dest_dir" 2>/dev/null
if cp "$file" "$dest"; then
echo "[COPY] $rel"
((count++))
else
echo "[FAIL] $rel"
fi
fi
done < <(find "$SOURCE_DIR" -type f -print0)
echo ""
echo "============================================"
echo " Copied: $count files"
echo " Skipped: $skipped files (already exist)"
echo "============================================"
echo ""