Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving Files
#1
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
Reply
#2
for directory use shutil.copytree and delete the source dir then
Reply
#3
(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
Reply
#4
I think you mean shutil.move(x, dst)
Reply
#5
(Oct-01-2019, 04:28 PM)Gribouillis Wrote: I think you mean shutil.move(x, dst)

Thank you so much Dude
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Moving specific files then unzipping/decompressing christophereccles 2 2,357 Apr-24-2021, 04:25 AM
Last Post: ndc85430
  Moving files to Folders giddyhead 13 9,134 Mar-07-2021, 02:50 AM
Last Post: giddyhead
  Moving Files From Subdirectories To Another Directory Harshil 5 3,992 Oct-06-2020, 10:52 AM
Last Post: ndc85430
  Some help with moving files ACSpeck 1 2,683 Apr-11-2018, 01:01 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020