[英]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. 因此,这为我创建了一个名为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)
这将允许您为新创建的文件夹创建子文件夹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.