Update code
This commit is contained in:
14
Moodle/SH/rename_topics.sh
Normal file
14
Moodle/SH/rename_topics.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lấy thư mục hiện hành nơi người dùng đang gọi lệnh
|
||||
TARGET_DIR="$(pwd)"
|
||||
|
||||
# Đổi tên các thư mục con cấp 1 theo mẫu: 1 - ABC → 1. ABC
|
||||
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 -type d -regextype posix-extended -regex '.*/[0-9]+ - .+' | while read dir; do
|
||||
base=$(basename "$dir")
|
||||
newname=$(echo "$base" | sed -E 's/^([0-9]+) - (.+)$/\1. \2/')
|
||||
if [ "$base" != "$newname" ]; then
|
||||
echo "🔁 Đổi tên: $base → $newname"
|
||||
mv "$TARGET_DIR/$base" "$TARGET_DIR/$newname"
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user