Given a source folder and a target folder, here is a function that returns an array containing all items in the target folder that are not in the source folder.

Function GetMissingItems(sourceFolder as FolderItem, targetFolder as FolderItem) as FolderItem()
  If sourceFolder is nil then
    dim nullList(-1) as FolderItem
    Return nullList
  End if
  If targetFolder is nil then
    dim nullList(-1) as FolderItem
    Return nullList
  End if

  dim d as new Dictionary
  For i as Integer = 1 to sourceFolder.Count
    If sourceFolder.TrueItem(i) <> nil then
      d.Value(sourceFolder.TrueItem(i).Name) = sourceFolder.TrueItem(i)
    End if
  Next

  dim theMissingItems(-1) as FolderItem
  For i as Integer = 1 to targetFolder.Count
    If targetFolder.TrueItem(i) <> nil then
      If not d.HasKey(targetFolder.TrueItem(i).Name) then
        theMissingItems.Append targetFolder.TrueItem(i)
      End if
    End if
  Next

  Return theMissingItems
End Function

Given two folders f1 and f2, two calls to GetMissingItems return two arrays that tell you which items are in one, but not the other. Perhaps you can use this to solve your problem.

I'm not surprised that you found nothing in the LR for FolderItemTrue or ItemTrue. Did you try looking for FolderItem.TrueItem, which is what I suggested earlier?

Charles Yeomans




On Mar 20, 2006, at 2:33 PM, Jeffrey Ellis wrote:

Charles Yeomans <charles at declareSub dot com> wrote:

The first problem I see is that the code uses Item, which resolves aliases, instead of TrueItem. If this code encounters an alias, strange things will happen. Otherwise I'm lost as well; I have no idea what it is you're trying to
do. Perhaps you could explain that first.

Charles Yeomans

Hi, Charles--

Good idea.

I’m trying to compare two folders, a Source Folder and a Target Folder. I then want to find if any files that are missing -- which exist in one folder but not in the other. In the list of files for both sides, I’d like to see the filename, and the absolutepath for the file. As a last step, I want to be able to have a pushbutton copy any files which don’t exist in one over to
the other, in the same location relative to the root folder examined.

I’ve done some further testing, and found something odd with the recursion.

          TargetName = TargetFolder.Item(index).Name
          TargetPath = TargetFolder.Item(index).AbsolutePath
          TargetList.AddRow itemInFolder.Name
          TargetDict.Value(TargetName) = TargetPath

TargetList.Cell(TargetList.LastIndex,1)=ReplaceAll(TargetPath,":","/")

In this snippet, the path is assigned to a variable. When used this way, the
paths all come out wrong. But, when the variable is not used:

          TargetName = TargetFolder.Item(index).Name
          TargetPath = TargetFolder.Item(index).AbsolutePath
          TargetList.AddRow itemInFolder.Name
          TargetDict.Value(TargetName) = TargetPath

TargetList.Cell(TargetList.LastIndex,1)=ReplaceAll(itemInFolder.Absolut epath
,":","/")

The paths now come out right.

I did a search for FolderItemTrue, and ItemTrue in the LR and found nothing. Could you tell me how to change my code to have this be used? It’s obviously
what I need anyway, since I want an accurate representation of the two
folders.

But the main problem I’m having now is with both the copying and the way the filenames are being stored in the dictionaries. Basically, they are being truncated to OS9 style filename length: “This is an OS X filename which can
have a lot of characters and so on and so on.txt” to “This is an OS X
filena#87653f5”.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to