Python programmers ...
 
Notifications
Clear all

Python programmers - "robocopy" script that simultaneously preserves MAC times AND displays individual file copy progress

4 Posts
2 Users
0 Likes
2,738 Views
(@balderdash11)
Posts: 6
Active Member
Topic starter
 

Good morning all,

I work with Windows machines at my job and I am fairly new to Python and programming in general.  I'm currently working on a Python program that copies all the files/folders contained in a given directory to a target directory.  The goal of this script is to preserve MAC times from the original files after the copy is complete.  I am utilizing the popular Python "shutil.copy2" function that preserves last access/last modified dates/times, and have enhanced this with a couple third party libraries to also preserve the created date/time.  My question is this - does anyone know if I can somehow add some code to shutil.copy2 that would dynamically display the copy progress (e.g. percentage complete) of INDIVIDUAL files as they pass through the script?  I understand that this specific functionality is not native to shutil.copy2 and I suspect that I would need to write my own custom copy function in order to display this progress for the user, but I'm not sure.

As it stands, my script works and displays the percentage complete of the OVERALL copy progress after each individual file has completed its copy, but I would like to see this progress on a more granular level.  For my job, I mostly copy segmented E01 images where each segment can be quite large and take a long time to process.  Without a way to display the progress of each file, the user is left with a significant period of hang time where no script feedback is provided.

Any advice or examples of code that would accomplish my criteria would be greatly appreciated.  I can also provide samples of my script if that helps anyone here.

 
Posted : 23/10/2020 3:20 pm
jaclaz
(@jaclaz)
Posts: 5133
Illustrious Member
(@balderdash11)
Posts: 6
Active Member
Topic starter
 

I tried incorporating some of that person's code into mine and got it working in a basic manner, although it will need some refining.  Regardless, this gives me something to work with.  Thank you!

 
Posted : 24/10/2020 2:34 am
jaclaz
(@jaclaz)
Posts: 5133
Illustrious Member
 

Good, you are welcome.

jaclaz

 
Posted : 24/10/2020 9:39 am
Share: