storme Posted May 7, 2011 Share Posted May 7, 2011 I've written a script to copy an important backup from the main hard drive to a USB hard drive. Because the file is so important I decided to do a _Crypt_HashFile of the main file then compare it to the version copied to the usb drive. Func FileCopyAndCheck($fileName, $source, $destination, $flag = 0) ;Success = ; Failure @error = 1 ; Copy failed ; @error = 2 ; Copy worked but files are different LogState($hLogFile, "Copy From:" & $source & "\" & $fileName & " To:" & $destination) If FileCopy($source & "\" & $fileName, $destination, $flag) = 0 Then LogState($hLogFile, "ERROR: Unalbe to copy file From:" & $source & " To:" & $destination) Return SetError(1, 0, "Copy Failed") ElseIf _Crypt_HashFile($source & "\" & $fileName, $CALG_SHA1) <> _Crypt_HashFile($destination & "\" & $fileName, $CALG_SHA1) Then LogState($hLogFile, "ERROR: Unalbe to copy file From:" & $source & " To:" & $destination) Return SetError(2, 0, "Failed compare") EndIf Return 1 ; OK EndFunc ;==>FileCopyAndCheck Worked perfectly on the trial files...BUT... the backup file is 23GB (YEP LARGE FILE) and it takes forever to do the hash. Any suggestions on how to ckeck if the file was copied perfectly without wating for "ages" Thanks for any help! John Morrison aka Storm-E Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
smartee Posted May 7, 2011 Share Posted May 7, 2011 hi John,Maybe will be faster, why not give it a shot. Do post the results if you do Really hope this helps -smartee Link to comment Share on other sites More sharing options...
MvGulik Posted May 7, 2011 Share Posted May 7, 2011 (edited) Yep. Do the scanning in low propriety in the background, and make it popup a reminder when its done. Ergo: No need to wait for it.Unless you got some data/facts suggesting its doing it relative slower than general normal sized files ... you just got a reality reminder. Big files take longer! ... hehe.--- --- ---Oh yea, Yep, Or use faster code of course. relative data in case you drop some stats.- time to copy file on USB drive. (or read it from USB if that's faster)- time to do the scan of the same file. (old way and new way) Edited May 7, 2011 by singularity "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
storme Posted May 7, 2011 Author Share Posted May 7, 2011 Yep. Do the scanning in low propriety in the background, and make it popup a reminder when its done. Ergo: No need to wait for it.Good idea but this is a scheduled batch task that runs a 4am every morning.The time probably isn't going to worry any one as it should be finished by the time they get in at 8am. BUT I’d prefer it to be finished long before they get in.Unless you got some data/facts suggesting its doing it relative slower than general normal sized files ... you just got a reality reminder. Big files take longer! ... hehe.I didn't realise their backup file had got so big.Initially I thought my script had crashed as it doesn't give any feedback (no user watching it) except to a log file.Oh yea, Yep, Or use faster code of course. relative data in case you drop some stats.- time to copy file on USB drive. (or read it from USB if that's faster)- time to do the scan of the same file. (old way and new way)Can't give you any of that that computer isn't here and I didn't have a drive big enough to take the file with me.It's even going to be difficult here as I don’t have that large a USB drive to test with. I was hoping someone had an alternative that would speed things up.I'm even contemplating using the dos copy command with a /V to do the copy and verify. Just have to find out how to capture the return code.Thanks for the help! Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E Link to comment Share on other sites More sharing options...
ProgAndy Posted May 7, 2011 Share Posted May 7, 2011 Hashing requires reading of the whole file, so you can remove the hashing and just compare the two files directly. This could be faster. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Danny35d Posted May 7, 2011 Share Posted May 7, 2011 I know must likely you want to use autoit and this is out of the subject, but a large file like that I will use rsync for windows. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now