Python Forum

Full Version: Moving Files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Newbie Alert

import os
import glob
import shutil

path = input('Enter folder location: ')
os.chdir(path)

try:
    os.makedirs('videos')

except FileExistsError:
    pass

dst = path + r"\videos"

for x in glob.glob('*.mp4'):
    shutil.move(path, dst)
print('Moved Successfully')    
Output:
shutil.Error: Cannot move a directory
for directory use shutil.copytree and delete the source dir then
(Oct-01-2019, 04:07 PM)Axel_Erfurt Wrote: [ -> ]for directory use shutil.copytree and delete the source dir then

No, I don't want to move dir
I have an Instagram image scrapper
I just want to keep videos separated in another dir
I think you mean shutil.move(x, dst)
(Oct-01-2019, 04:28 PM)Gribouillis Wrote: [ -> ]I think you mean shutil.move(x, dst)

Thank you so much Dude