Charles Yeomans <charles at declareSub dot com> wrote:
> 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
heh. No, I didn¹t, sorry :)
Yes, found it fine now. And thank you for the snippet...!
It looks at this point that my issue is with the filename truncation and
with not being able to copy over missing folders, packages, etc., as opposed
to files.
This code works perfectly for files, but not for folders/packages:
dim sourcepath,targetpath,sourcerootpath,targetrootpath as string
dim i, count as integer
dim f,g as folderitem
count=0
for i=0 to TargetList.listcount-1
if TargetList.cell(i,2) <> "" then
sourcepath=TargetList.cell(i,1) //this is the cell where the
absolutepath to the source file is stored
sourcerootpath=TargetList.cell(i,3) //this is the cell where the
absolutepath to the source root folder is stored
targetrootPath=TargetList.cell(i,2) //this is the cell where the
absolutepath to the target root folder is stored
targetpath=Replace(sourcepath,sourcerootpath,targetrootPath)
//replace the source root folder with the target root folder to get the
correct path for the CopyFileTo
f=GetTrueFolderItem(sourcePath)
g=GetTrueFolderItem(targetPath)
If g.exists = false and f <> Nil then
f.CopyFileTo(g)
MsgBox "success!"
count=count+1
else
MsgBox "Bad"
end if
end if
next
MsgBox cstr(count)+" files copied."
All My Best,
Jeffrey
_______________________________________________
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>