Burgaud Posted May 19, 2020 Share Posted May 19, 2020 Assume I want to move files from local drive to an external detachable drive should that drive is detached/not available, move it to another local drive What is the best practice? Assume $Repository is the Folder in the detachable drive Assume $LocalDrive is the Folder to another local drive Should I: if FileExists($Repository) then Filemove(...., $Repository....) else FileMove( ...., $LocalDrive...) endif or If NOT FileMove( ...., $Repository..) then FileMove(...$LocalDrive....) endif? I know both will work, but what is the best practice? I assume doing the FileExists one is better. What do you think? Thanks! Link to comment Share on other sites More sharing options...
careca Posted May 19, 2020 Share Posted May 19, 2020 Since you're talking about moving files to different drives, you should know that it's not really going to move them, but instead it copies. So as a general rule, and if you want to do it proper, i'd say you do a FileExists on the drive for the destination, then a FileGetSize on the original file, then do a copy, and then another FileGetSize on the destination file. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
seadoggie01 Posted May 19, 2020 Share Posted May 19, 2020 3 hours ago, careca said: it's not really going to move them, but instead it copies What? Please explain what you mean by this. I just tried this and it moves the files across drives for me All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
careca Posted May 19, 2020 Share Posted May 19, 2020 Has to copy, the file doesn't exist in the other drive. As stated in the remarks for filemove: "If the source and destination paths are on different volumes a copy and delete operation is performed rather than a move." Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
spudw2k Posted May 20, 2020 Share Posted May 20, 2020 To @careca's point, technically the file move operation between volumes is a copy from source, then a deletion from source after the copy. Not sure how important that detail is as far as accomplishing the goal of moving a file, but I suppose it's useful to know how it works. Also, due to the nature of how it works, I would expect that there is some sort of successful copy validation already inherent in the process before it deletes the original, otherwise if the move didn't actually copy the file accurately and deleted the original you'd be at risk of losing integrity of the file data and be screwed. If you are really worried about it, perhaps perform the copy yourself, compare the two files, then delete the original. If I was worried checking a transferred file I might employ something to verify integrity more precisely than file sizes (i.e. a hash/checksum comparison). argumentum 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
careca Posted May 20, 2020 Share Posted May 20, 2020 (edited) I agree, a checksum is a better idea. Found a post with it #include <Crypt.au3> ;Get SHA1 Local $File = FileOpenDialog("Select a file", EnvGet("systemdrive"), "All (*.*)") _Crypt_Startup() $sha1 = _Crypt_HashFile($File, $CALG_SHA1) MsgBox(64 + 262144, '$sha1', $sha1) _Crypt_Shutdown() Edited May 20, 2020 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe 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