Jul-14-2019, 07:52 PM
Hey guys I know that this issue has already been adressed in a previous threads (https://stackoverflow.com/questions/2207...files-fast ), but I didn't manage to apply the solution to my own code (sorry, I'm rather new to Python) so I thought I´d ask again. Here´s my problem:
I created a simple app that compares the content of two folders and copies the new files of one folder into the other (I used the filecmp-statement for the comparison, so far so good). As for the copy-part, I used the shutil.copy-module.
As it has already been discussed in previous threads, the shutil.copy-module is way slower than the native command for copying files in windows (e.g. it took my code about 94 seconds to copy 800MB, while it took the ordinary copy and paste method in windows about 30 seconds for the same files).
I would be really grateful if somebody could have a look at my code and tell me how to implement a faster copying method (e.g. subprocess.call or native command) in my code. Thanks in advance for your help!
I created a simple app that compares the content of two folders and copies the new files of one folder into the other (I used the filecmp-statement for the comparison, so far so good). As for the copy-part, I used the shutil.copy-module.
As it has already been discussed in previous threads, the shutil.copy-module is way slower than the native command for copying files in windows (e.g. it took my code about 94 seconds to copy 800MB, while it took the ordinary copy and paste method in windows about 30 seconds for the same files).
I would be really grateful if somebody could have a look at my code and tell me how to implement a faster copying method (e.g. subprocess.call or native command) in my code. Thanks in advance for your help!
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import shutil import filecmp import os comparison = filecmp.dircmp(r "C:\Users\j2the\Documents\Test2" , r "C:\Users\j2the\Documents\Test1" ) def analyze(): for e in comparison.right_only: print (e) os.chdir(r "C:\Users\j2the\Documents\Test1" ) shutil.copy(e, r "C:\Users\j2the\Documents\Test2" ) analyze() |