Created
January 16, 2014 03:12
-
-
Save 0x4a/8449228 to your computer and use it in GitHub Desktop.
#ahk #frontend to gnu #diff #tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv | |
#SingleInstance, force | |
SetWorkingDir %A_ScriptDir% | |
FileEncoding UTF-8 | |
args = %0% | |
a_old = %1% | |
a_new = %2% | |
global timestamp, diffout | |
global log := SubStr(A_ScriptName, 1, -4) ".log" | |
SplitPath, a_new,, savedir,, basename | |
diffout := savedir "\" basename ".diff" | |
FormatTime, timestamp, , dd.MM. HH:mm:ss tt | |
diffpath = "c:\Program Files (x86)\GnuWin32\bin\diff.exe" | |
diffargs = -U3 -Bib | |
if (args <> 2) ; two arguments | |
logMessage("wrong number of arguments: " . args . " found, 2 expected", "error") | |
else if (!FileExist(a_old)) ; two files | |
logMessage("file not found: " . a_old, "error") | |
else if (!FileExist(a_new)) | |
logMessage("file not found: " . a_new, "error") | |
logMessage("--- " . a_old . "`t`t+++ " . a_new, "comp") | |
RunWait, %comspec% /c %diffpath% %diffargs% %a_old% %a_new% > %diffout%, , Hide UseErrorLevel | |
if ErrorLevel = ERROR | |
logMessage("Diff could not be launched from " . diffpath, "error") | |
else | |
logMessage(">>> " . diffout, "save") | |
exit | |
logMessage(text, mode = "info") { | |
StringUpper, mode, mode | |
FileAppend, [%timestamp%] [%mode%] %text%`n, %log% | |
if mode = ERROR | |
{ | |
Msgbox,262208 , %mode%, %text%`n`n`nUsage:`n%A_ScriptName% <oldfile> <newfile> | |
Exit | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment