Move, copy, overwrite files in Python using Python Shutil

preview_player
Показать описание
#LetslearnPython
#movecopyfilesPython
#AutomateWithPython
In this video we will learn to move files, copy files, and overwrite files with Python using Shutil.
Python's built-in shutil module does have a few "quirks" that you need to be careful of.
Moving or copying files can lead to files being overwritten.
We will also running into permissions errors.
I will teach you how to overcome these "quirks", so your Python code will be free of surprises or "gotchas"

You can find the notebook here in my Python stuff repository:

Рекомендации по теме
Комментарии
Автор

Great job. You deserve more viewers keep up with the great work

effabe
Автор

Dude, you have no idea how much this helped me! Def underrated channel, you're awesome:)

thekingofpuppets
Автор

Thank you very much for this video! It helped me get familiar with shutil and how to use the various functions!

tymothylim
Автор

You can move your files the way you intended first time, but all it takes is deleting the code segment, which copied files. So, you first copy files, then you move the same files and get an error. But if you move those files without copying, it works okay.

ShaolinMonk
Автор

Thanks, I would like to ask if there is a way to track file name origin and destination directories when I do copy and paste event or sent to command on windows operating system using Python

sairgai
Автор

Man, this actually works. Keep it great!

DeTodoNoticias
Автор

I'm already at the part where I move files that already exists in FOLDER B. I wrote the same code block that you wrote but I'm still getting this error. :(

raise Error("Destination path '%s' already exists" % real_dst)

It says that my file1.txt already exists in FOLDER B. I reviewed the code and saw nothing wrong (in my opinion). Is there any other way to overwrite the existing files? I can remove them first before moving the files but overwriting the files is the better approach I think.

aljohnrhey
Автор

Hi I have a question.
I want to copy few files from C DRIVE - PROGRAM 86X - FILE XXX TO C DRIVE - WINDOWS - SYSTEM and paste it. Systems will prompt me to select all and continue to copy/paste.. how to write the python script for this could you help me plz.. thank you

sirishraj
Автор

I received this error when I ran
"for file in files:
with open(files) as f:
print(files, f.read())"

PermissionError Traceback (most recent call last)
in <module>
1 for file in files:
----> 2 with open(file) as f:
3 print(file, f.read())

PermissionError: [Errno 13] Permission denied: 'main'

sgracem
Автор

what does shutil stand for? Assuming util = utilities. but what's the sh?

Sean
Автор

How can we copy a file from source to destination based on date


if suppose i have a file called SAM 12-11-19 in my source
i want to copy that file based on date
if the file with that date already exists in destination copying needs to ignore and search for the new file which is not in my destination


can you help me on this

ashokaddanki
Автор

will the same thing work even the files are pics, i.e, JPG files?

gowrishankarreddy