LoginSignup
1
1

同じディレクトリ構成のままコピーする

Posted at
import shutil
import os


input_path = "C:/Users/hoge/Desktop/プログラミング/python/プログラム/sample02/module03"
input_path_list = input_path.split("/")

output_path = "./output"

for path in input_path_list[input_path_list.index("python") :]:
    output_path = os.path.join(output_path, path)

try:
    shutil.copytree(input_path, output_path)

except Exception as e:
    print(e)

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