_index.md 파일 제거
스크립트
- remove_index.py
import os
def remove_index_md_files(directory):
for root, dirs, files in os.walk(directory):
dirs[:] = [d for d in dirs if not d.startswith('.') and not d.startswith('_')]
for filename in files:
if filename == '_index.md':
file_path = os.path.join(root, filename)
try:
os.remove(file_path)
print(f'Removed: {file_path}')
except OSError as e:
print(f'Error removing {file_path}: {e}')
# 예시 디렉토리 경로
source_dir = os.environ.get('SOURCE_DIR', r"D:\obsidian")
remove_index_md_files(source_dir)
기능
- 각 디렉토리에서
_index.md
파일을 찾고 삭제합니다.