Skip to content

Commit

Permalink
find 파일명 문제
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenPearls authored Aug 28, 2024
1 parent ec049fd commit 5dc1cac
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions .github/workflows/Rename and Commit Markdown Files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,6 @@ jobs:
- name: Rename and Add New Markdown files # Markdown 파일을 이름 변경 및 복사
run: |
for file in $(find developLog -type f -name '*.md'); do
# README.md 및 SUMMARY.md 파일은 건너뜀
if [[ "$file" == *"README.md" ]] || [[ "$file" == *"SUMMARY.md" ]]; then
echo "Skipping $file" # 해당 파일은 건너뜀
continue # 다음 파일로 진행
fi
# 파일 내용의 첫 번째 제목 줄을 추출
title=$(grep -m 1 '^#' "$file")
if [ -n "$title" ]; then
# 파일의 디렉토리 구조를 유지하면서 제목을 기반으로 새 파일명 생성
dir=$(dirname "$file")
new_filename="$dir/$title.md"
# 파일 이름이 동일한 경우에도 강제로 업데이트
if [ "$file" != "$new_filename" ]; then
echo "Renaming $file to $new_filename"
mv "$file" "$new_filename"
else
echo "Updating timestamp for $file"
touch "$file" # 파일의 타임스탬프를 업데이트
fi
else
echo "No valid title found in $file, skipping."
fi
done
# developLog 디렉토리에서 .md 파일을 모두 찾음
find developLog -type f -name '*.md' | while IFS= read -r file; do
# README.md 및 SUMMARY.md 파일은 건너뜀
if [[ "$file" == *"README.md" ]] || [[ "$file" == *"SUMMARY.md" ]]; then
Expand All @@ -69,10 +40,11 @@ jobs:
# 기존 파일명을 유지한 채 새 파일명으로 복사
if [ "$file" != "$new_filename" ]; then
echo "Copying $file to $new_filename" # 복사 작업 로그 출력
cp "$file" "$new_filename" # 새 파일명으로 파일 복사
echo "Renaming $file to $new_filename" # 복사 작업 로그 출력
mv "$file" "$new_filename" # 새 파일명으로 파일 복사
else
echo "No need to rename $file" # 파일명이 같으면 로그 출력
echo "Updating timestamp for $file" # 파일명이 같으면 로그 출력
touch "$file" # 파일의 타임스탬프를 업데이트
fi
else
echo "No valid title found in $file, skipping." # 유효한 제목이 없으면 로그 출력
Expand Down

0 comments on commit 5dc1cac

Please sign in to comment.