Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare project files with files in directory structure 1

Status
Not open for further replies.

LinguaFranca

Technical User
Jan 4, 2005
18
NL
I am a beginner in VBA, so bear with me!
I've got a project folder (of a translation tool) containing big files and the script is searching for new .big files. I then need to compare found files with the already existing files in my project folder. There is an error in my looping.

Sample files in dir:
carmen.big (new)
sea.res.big (already existing in project folder)
sea.frm.big (already existing in project folder)

I successfully find the already existing files in my project folder but when it comes to the new file which I eventually would like to import it finds carmen.big plus sea.res.big plus sea.frm.big. This because compares the dir file name with each file name in my project. They are not matching to my script but I don't know how to tweak the loop to tell read all my files in my project and if it matches once then discard the file name you are finding in the directory.



Code:
'Tree search in subfolders
Dim fso As New FileSystemObject
Dim f As Folder, sf As Folder, fi As File

Set f = fso.GetFolder(path)
For Each sf In f.SubFolders
  LoopFoldersListFiles (sf.Path)
Next
For Each fi In f.Files
  strExt = LCase(Mid(fi.Path, 1+InStrRev(fi.Path,".")))
  Dim prj As PslProject
  Set prj=PSL.ActiveProject
  Dim src As PslSourceList


  If strExt = "big" Then
    Dim foundFile As String
    foundFile=fi.Name

	'list .big files in dir structure
  	PSL.Output "Found file: " & foundFile

	  'loop through all project files
  	  For Each src In prj.SourceLists
		Dim oldFile As String
  		oldFile=src.Title & ".big"

		'list all available .big files in project
  		PSL.Output oldFile

		If ((foundFile=oldFile)=True) Then
		  PSL.Output "identical file found: " & oldFile
		ElseIf ((foundFile=oldFile)=False) Then
		  GoTo loopBreak1
		End If
	Next src

	loopBreak1:
	If ((foundFile=oldFile)=False) Then
	  'final goal is to import foundFile (new) from dir here
  	  PSL.Output "new file for import found: " & foundFile
	End If

   End If

Next
 
Code:
...
        PSL.Output oldFile
        If foundFile = oldFile Then
          PSL.Output "identical file found: " & oldFile
          Exit For
        End If
    Next src
    If foundFile <> oldFile Then
      'final goal is to import foundFile (new) from dir here
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Excellent! Thank you very much. Again, you helped me a lot.
Carmen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top