
Pythonで
・フォルダを移動
できます!
コード
ここでは例として
・デスクトップ配下のフォルダ「folder01」をフォルダ「temp」配下へ移動
させます。
※デスクトップ上に下記コードを記載した「sample.py」を作成します。
import shutil
# 移動させるフォルダのパス
folder_path = r'C:\Users\lunch\Desktop\folder01'
# 移動先のフォルダパス
new_folder_path = r'C:\Users\lunch\Desktop\temp'
try:
# フォルダを移動
shutil.move(folder_path,new_folder_path)
except Exception as e:
print(e)
実行結果
フォルダを移動できました。


参考
上記で使用した以下の詳細は、公式サイトをご確認ください。
●標準ライブラリ「shutil」モジュールの「move」