up
up
This commit is contained in:
26
SH/scan.sh
Normal file
26
SH/scan.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Thư mục gốc của khóa học
|
||||
COURSE_FOLDER="$(pwd)"
|
||||
|
||||
# Tìm tất cả các thư mục con
|
||||
mapfile -t DIRS < <(find "$COURSE_FOLDER" -type d)
|
||||
|
||||
for dir in "${DIRS[@]}"; do
|
||||
relative_path="${dir#*/vod/}"
|
||||
OUTPUT_JSON="$dir/filelist.txt"
|
||||
|
||||
# Xóa tệp mdl.media cũ nếu tồn tại
|
||||
rm -f "$OUTPUT_JSON"
|
||||
|
||||
# Tìm và sắp xếp các file .pdf và .xlsx theo thứ tự tự nhiên
|
||||
mapfile -d '' -t FILES < <(find "$dir" -maxdepth 1 -type f \( -name '*.pdf' -o -name '*.xlsx' \) -print0 | sort -z -V)
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
filename=$(basename "$file")
|
||||
vid="$relative_path/$filename"
|
||||
echo "$vid" >> "$OUTPUT_JSON"
|
||||
done
|
||||
|
||||
echo "File filelist.txt created successfully in $dir."
|
||||
done
|
Reference in New Issue
Block a user