LoginSignup
1
1

More than 1 year has passed since last update.

Pythonで一つのディレクトリに一気に複数フォルダを作成する方法

Posted at

どうもエンジニアのirohasです。

今回はちょっとしたPythonの情報共有ができればと思い記事を投稿します。

内容としては、タイトルの通り、複数のフォルダを一気に作成しよう!というやつです。

ソースコードは以下になります。

make.py
import os

path_list = ["作成したいフォルダ名たちを格納"]

for dir in path_list:
    if not os.path.exists(dir):
        os.mkdir(dir)

まずは作成したいフォルダ名たちを格納したリストを作り、それをfor文で回し、
標準ライブラリであるosモジュールを使って要素ずつフォルダを作成していく形になります。
いくらでも作成可能なので是非みなさんも機会があれば使ってみてください!!!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1