简体   繁体   English

Python-如何在新创建的目录中创建多个文件夹?

[英]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.

相关问题 如何压缩在Python程序中新创建的文件夹? - How to zip folders that are newly created in Python program? Python:如何在Linux的特定目录中查找上一个小时创建的新文件夹/目录 - Python: How can i find new folders/directories created in last hour in a specific directory in Linux 如何在多个文件夹中创建相同的多个文件夹? - How can I create the same multiple folders in many Folders? 在一个目录中创建多个文件夹 - create multiple folders in a directory 如何在一个目录中创建多个文件夹? - How to create multiple folders inside a directory? Pandas:如何使用现有列和新创建列中的先前行创建新列? - Pandas : How can I create new column using previous rows from existing column and newly created column? 如何合并两个新创建的列并创建一个列来划分两者 - How can I combine two newly created columns and also create a column for the division of both Python:将文件移动到新创建的目录 - Python: moving file to a newly created directory 如何使用Twilio Python客户端邀请用户加入新创建的私人聊天频道? - How can I invite a user to a newly created private chat channel using the Twilio Python Client? 如何使用python gimp替换新创建的图像上的一个图像? - How can i replace one image on a newly created image with python gimp?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM