



ps1 script is not a lot more complicated than writing a batch file. PowerShell is a standard part of Windows as well and writing a. However, I can appreciate wanting to be extra sure, so it would be fairly simple to string something like robocopy together with cmdlets like Get-FileHash from PowerShell. I think that's mainly because you can pretty much rely on utilities like robocopy (standard Windows) to fail if there's a problem and to rest assured your copy is good if it completes without error. Another reason to rewrite could be because you have a clever idea on how to do it better, but that's where other languages are almost guaranteed to outperform Python.įollow-up to comment: there's no single utility in Windows that does a 'safe-copy' in one go, that I'm aware of. Rewriting can make sense to learn more about how they work internally, but you'll likely find yourself abandoning the work once you understand them. In almost any real world project, it would much more sense to combine/package several of those and script them together using a batch language (or perhaps Python) than to rewrite them from the ground up. There exist thousands of file management utilities that have been developed for decades and are highly optimised, for speed or for very specific functions. (Don't just run this script if you have an actual C:\temp\a.txt file, obviously) The program you described could be as simple as: from pathlib import Pathįor chunk in iter(lambda: f.read(chunk_size), b''): If you do want to continue developing this in Python regardless, you should definitely read through the standard modules os, shutil, pathlib and hashlib. A language like C++ or Rust might make more sense to learn if that's your passion. Just keep in mind that Python is not at all an optimal language for something that ultimately relies heavily on performance. For any starting programmer, it definitely makes sense to dive deeply into something that interests you - if, in your case, that's file management, that's fine of course.
