import os import pyperclip # 获取当前脚本的路径 script_dir = os.path.dirname(os.path.abspath(__file__)) # 从剪贴板获取文件名列表,假设每行一个文件名 file_names = pyperclip.paste().strip().split('\n') # 遍历文件名列表,为每个文件名添加排序前缀并创建文件 for index, file_name in enumerate(file_names, start=1): # 去除文件名两端的空白字符 file_name = file_name.strip() # 添加排序前缀和.md后缀 file_name_with_prefix = f"{index:02d}-{file_name}.md" # 这里使用3位数的排序前缀,可以根据需要调整 # 构建文件的完整路径 file_path = os.path.join(script_dir, file_name_with_prefix) # 创建文件 with open(file_path, 'w') as file: # 如果需要写入初始内容,可以在这里添加 # 例如:file.write("This is the content of the file.") pass # 如果不需要写入内容,则使用pass print(f"Files created successfully in {script_dir}")