jbsoccerbrit Posted May 12, 2009 Posted May 12, 2009 I am looking for suggestion on how to design a tool that would allow a user to swap a file from a selection list. The files for selection may well have the same names as each other but when implemented do different things. For example in the list there might be two files called 8i000000.000 but when replacing the file in the software I am using the files do different things. In basic the tool just has to replace the currently existing 8i000000.000 at the software set location with a new one instead of me having to copy and paste it over each time. Other files may also exist in the selection like 8c000000.000 If anyone has any suggestion that would be great
lordicast Posted May 12, 2009 Posted May 12, 2009 This should get you started it runs a function that according to where your old and new dir's are notify's you if you want to copy the new file with the same name to the working folder each time its ran. cheers expandcollapse popup#include <File.au3> #include <Array.au3> HotKeySet('{esc}','Done') HotKeySet('{f1}','Check') $Dir2 = 'C:\Dir Source' ;File Souce where files are copied from (new) $Dir = ' C:\Working Dir' ;Where files are found and replaced Check() while 1 Sleep(100) WEnd func Done() Exit 0 EndFunc Func Check() $List = _FileListToArray($Dir) _ArraySort($List, 0, 1) $FileSource = _FileListToArray($Dir2) _ArraySort($FileSource, 0, 1) $Files = _ArrayToString($FileSource, @CRLF, 1) $FileO = FileOpen(@scriptdir & '\quick.ref',10) FileWrite($FileO,$Files) FileClose($FileO) $FileOA = FileOpen(@scriptdir & '\quick.ref',0) $FileSR = FileRead($FileOA) FileClose($FileOA) for $i =1 to $List[0] If StringInStr($FileSR,$List[$i]) = 0 Then Else $MSG1 = MsgBox(4,'Match','File: ["' & $List[$i]& '"] matches a replacement available would you like to replace?') If $MSG1 = 6 Then FileDelete($Dir &'\'& $List[$i]) FileCopy($Dir2 &'\'& $List[$i],$Dir &'\'& $List[$i]) Else Sleep(100) EndIf EndIf Next FileDelete(@ScriptDir &'\quick.ref') EndFunc [Cheeky]Comment[/Cheeky]
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