我刚刚接到了为大约500个客户创建一个新文件夹的任务。 Python是我熟悉的唯一代码,但我也愿意使用其他语言。我有一个excel中每个客户名称的列表,并且如果可能的话,我希望为每个名称创建一个新文件夹(如插图,建议和会议记录)。然后我将所有这些放在一个文件夹中,然后将那个大文件夹上传到框中。如果有人可以提供帮助,请告诉我
答案 0 :(得分:0)
如前所述,您应该调查csv
库,但如果这是一次性操作,并且看到只有500个客户端,那么将500个客户端粘贴到以下脚本中可能更简单:
import os
names = """
Adam Adams
Betty Bo
Carl Carter
Denise & David Daniels"""
sub_categories = ["Illustrations", "Advice", "Meeting Notes"]
root_folder = "c:/clients"
for name in names.split("\n"):
# Sanitise the name (remove any extra leading or trailing spaces)
name = name.strip()
# Skip any blank lines
if name:
# Remove some illegal characters from the name (could be done using RegEx)
for item in ["&", "/", "\\", ":"]:
name = name.replace(item, " ") # Convert to spaces
name = name.replace(" ", "") # Remove any double spaces
# Create all the folders for this client name
for sub_category in sub_categories:
os.makedirs("%s/%s/%s" % (root_folder, name, sub_category))
在Python 2.7中测试