jsonl
This commit is contained in:
31
copied.py
Normal file
31
copied.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# 定义源文件夹和目标文件夹路径
|
||||
source_folder = '/home/ubuntu/50T/fsy/wl/articles/mds' # 替换为实际的源文件夹路径
|
||||
destination_folder = '/home/ubuntu/50T/fsy/wl/articles/only_mds'
|
||||
|
||||
if not os.path.exists(destination_folder):
|
||||
os.makedirs(destination_folder)
|
||||
|
||||
# 遍历源文件夹及其子目录
|
||||
for root, dirs, files in os.walk(source_folder):
|
||||
for file in files:
|
||||
# 检查文件扩展名是否为 .md
|
||||
if file.endswith('.md'):
|
||||
# 构造完整的源文件路径
|
||||
source_file = os.path.join(root, file)
|
||||
# 构造目标文件路径
|
||||
destination_file = os.path.join(destination_folder, file)
|
||||
|
||||
# 如果目标文件已存在,则重命名或跳过(避免覆盖)
|
||||
if os.path.exists(destination_file):
|
||||
base_name, ext = os.path.splitext(file)
|
||||
count = 1
|
||||
while os.path.exists(destination_file):
|
||||
destination_file = os.path.join(destination_folder, f"{base_name}_{count}{ext}")
|
||||
count += 1
|
||||
|
||||
# 移动文件
|
||||
shutil.copy2(source_file, destination_file)
|
||||
print(f"Copied: {source_file} -> {destination_file}")
|
||||
Reference in New Issue
Block a user