AutoHotkey Community

It is currently May 24th, 2012, 8:32 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: March 18th, 2007, 5:44 pm 
Offline

Joined: January 14th, 2006, 8:59 pm
Posts: 3
Location: Tooele, UT
Hey I'm kind of a newish coder and I was wondering if there was anyone out there that could write a script that would compare the content of two folders and say which files weren't in one or the other.

Thank you in advance.

Forever
Φφ Phi-Rho Φφ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2007, 11:00 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
I am working on such script, for my own needs (management of translations for a PHP application). It isn't very hard to do, but I have little time. Will update here later.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2007, 4:46 am 
Online
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8643
Location: Salem, MA
a very good free program that will tell you this is winmerge (winmerge.sf.net)

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 20th, 2007, 9:25 am 
Offline

Joined: July 6th, 2004, 10:07 am
Posts: 171
Location: Manchester, England.
@bradglaser,

Quick + dirty solution, but fast

Code:

;; check for files that ARE on h:\ that are NOT on g:\
;; does NOT perform a copy ! only informs what WOULD be copied :)

RunWait , %comspec% /c xcopy h:\*.* g:\*.* /s /y /d /l >> difference.txt , , hide

msgbox Done



_________________
Simple ideas lie within reach, only of complex minds


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Here it is
PostPosted: March 20th, 2007, 11:21 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Neither very much tested (but seems to behave reasonably well) nor optimized!
Code:
;~ dir1 = D:\www\ZC-1.3.7\includes\languages\english
;~ dir2 = D:\www\ZC-1.3.7\includes\languages\french
dir1 = E:\javalib1
dir2 = E:\javalib2
;~ fileMask = *.php
fileMask = *.jar

Loop %dir1%\%fileMask%
{
   fileList1 .= A_LoopFileName . "`n"
   fnb1 := A_Index
}
StringTrimRight fileList1, fileList1, 1

Loop %dir2%\%fileMask%
{
   fileList2 .= A_LoopFileName . "`n"
   fnb2 := A_Index
}
StringTrimRight fileList2, fileList2, 1

Sort fileList1
Sort fileList2
StringSplit files_1_, fileList1, `n
StringSplit files_2_, fileList2, `n
idxF1 := idxF2 := 1

Loop
{
   If (files_1_%idxF1% = files_2_%idxF2%)
   {
      ; We are in synch
      list1 .= files_1_%idxF1% . "|"
      idxF1++
      list2 .= files_2_%idxF2% . "|"
      idxF2++
   }
   Else
   {
      ; Either file at idxF1 or at idxF3 is missing, we must find which one
      If (files_1_%idxF1% > files_2_%idxF2%)
      {
         ; Missing in first list
         list1 .= " |"   ; Empty
         list2 .= files_2_%idxF2% . "|"
         idxF2++
      }
      Else
      {
         ; Missing in second list
         list1 .= files_1_%idxF1% . "|"
         idxF1++
         list2 .= " |"   ; Empty
      }
   }
   If (idxF1 > fnb1)
   {
      Loop % fnb2 - idxF2 + 1
      {
         list1 .= " |"   ; Empty
         list2 .= files_2_%idxF2% . "|"
         idxF2++
      }
      Break
   }
   If (idxF2 > fnb2)
   {
      Loop % fnb1 - idxF1 + 1
      {
         list1 .= files_1_%idxF1% . "|"
         idxF1++
         list2 .= " |"   ; Empty
      }
      Break
   }
}

StringTrimRight list1, list1, 1
Gui Add, ListBox, w200 r20 vfiles1, %list1%
StringTrimRight list2, list2, 1
Gui Add, ListBox, x+20 w200 r20 vfiles2, %list2%

Gui Add, Button, w50 gGuiOK default, OK
Gui Add, Button, x+50 w50 gGuiClose, Cancel
Gui Show, w500
Return

GuiOK:
GuiClose:
GuiEscape:
ExitApp

I must find a way to synchronize the scrolling of the list boxes...
At worse, by providing Up and Down buttons between the lists.

Of course, this can be adapted to compare file content and such.
It won't make a good diff utility, as I must sort the data: file content comparison is much harder, I studied the topic a bit, it can lead to very CPU intensive algorithms, unless some tricks are used.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: dra, engunneer, Exabot [Bot], Google Feedfetcher, Ohnitiel, patgenn123 and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group