import os
import shutil
def copy_matching_arw_files():
# 获取当前工作目录
current_dir = os.getcwd()
# 收集所有JPG文件的基本文件名(不区分大小写)
jpg_basenames = set()
for filename in os.listdir(current_dir):
if os.path.splitext(filename)[1].lower() == '.jpg':
jpg_basenames.add(os.path.splitext(filename)[0])
# 收集匹配的ARW文件
arw_files = []
for filename in os.listdir(current_dir):
if os.path.splitext(filename)[1].lower() == '.arw':
basename = os.path.splitext(filename)[0]
if basename in jpg_basenames:
arw_files.append(filename)
if not arw_files:
print("未找到匹配的ARW文件")
return
# 创建目标文件夹
target_dir = os.path.join(current_dir, "ARW_Files")
os.makedirs(target_dir, exist_ok=True)
# 复制文件
for arw_file in arw_files:
src = os.path.join(current_dir, arw_file)
dst = os.path.join(target_dir, arw_file)
shutil.copy2(src, dst)
print(f"已复制: {arw_file}")
print(f"\n成功复制 {len(arw_files)} 个ARW文件到目录: {target_dir}")
if __name__ == "__main__":
copy_matching_arw_files()