forked from wandb/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs_move.sh
More file actions
29 lines (24 loc) · 833 Bytes
/
docs_move.sh
File metadata and controls
29 lines (24 loc) · 833 Bytes
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
#!/bin/bash
# Check if arguments are provided
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <content_file_path> <docs_file_path>"
echo "Example: $0 ./content/subdir/file.md ./docs/file.md"
exit 1
fi
# Input paths
content_file="$1" # Path to the file in the content directory (canonical location)
docs_file="$2" # Path to the corresponding file in the docs directory
# Check if the source file exists
if [[ ! -f "$docs_file" ]]; then
echo "Error: Docs file '$docs_file' does not exist."
exit 1
fi
# Ensure the destination directory exists
content_dir=$(dirname "$content_file")
if [[ ! -d "$content_dir" ]]; then
echo "Creating destination directory: $content_dir"
mkdir -p "$content_dir"
fi
# Move the file with git mv
echo "Moving $docs_file to $content_file"
git mv "$docs_file" "$content_file"