简体   繁体   中英

Python - How can I create multiple folders in a newly created directory?

I'm very new to this, Im essentially trying to create a script for working on feature films so that everyday I can have a new set of folders made for that specific shoot day that I can the offload files too.

So far I have been able to have a Folder made with the users input of which shoot day they are on and then add the actual date to that file name.

But where I am stuck is trying to add folders within this newly created folder.

print ('')
print '\033[4m' + "Hello, Please select a shoot day to begin - this only works up until 12pm" + '\033[0m'
import os
import sys
import time, datetime

today = datetime.date.today()  # get today's date as a datetime type

todaystr = today.isoformat()   # get string representation: YYYY_MM_DD
                               # from a datetime type.


print('')
user_input = raw_input('\033[1m' + 'Enter Shoot Day Here -' + '\033[0m')

path1 = user_input
if not os.path.exists(path1):
    os.makedirs(path1 +'_' + todaystr)

So this created me a folder called 015_2016-12-24. I then want to be able to add several folders with folders inside of these folders.

Just trying my best here sorry if this is a dumb question. Thanks for any help !

os.makedirs(path1 +'_' + todaystr+'/'+name of subfolder)

这将允许您为新创建的文件夹创建子文件夹

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM