0

I was just given the task to create a new folder on box for about 500 clients. Python is the only code I am familiar with, but I am willing to use another language as well. I have a list of each clients name in excel and would like to create a new folder for each name if possible with sub-categories (ex. Illustrations, Advice, and Meeting Notes). I will then put all of those in a folder and upload that one big folder to box. If anyone can help please let me know

1 Answers1

0

As mentioned, you should investigate the csv library, but if this is a one off operation, and seeing as there are only 500 clients, it might be simpler just to copy paste your 500 clients into the following script:

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))

Tested in Python 2.7

Martin Evans
  • 45,791
  • 17
  • 81
  • 97