Almost there (fileexists question)

Results 1 to 2 of 2

Thread: Almost there (fileexists question)

  1. #1
    Join Date
    Dec 1969

    Default Almost there (fileexists question)

    Here&#039;s my function:<BR><BR>Function IsFileExists(byVal FileFolder)<BR><BR>Dim objFSO<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR><BR>&#039;Set objFSO = CreateObject("Scripting.FileSystemObject")<BR><BR> Dim RootFolder, Fldr, RootSubFolders,fname,fyr,fmo,Path, Cust_Number, FileName<BR><BR>Cust_Number=request("cust_num")<BR ><BR>Set RootFolder = objFSO.GetFolder(Server.MapPath("/depconweb/"))<BR>Set RootSubFolders = RootFolder.SubFolders &#039;<BR> For Each Fldr in RootSubFolders<BR> fname = Fldr.Name <BR> fyr = Left(fname,4) <BR> fmo = Right(fname,2)<BR> FileName = Right(fyr,2)&fmo&"-"&Cust_Number<BR> &#039;Response.Write FileName<BR> Path = Server.MapPath("/depconweb/"&fname&"/"&FileName&".pdf")<BR> &#039;Response.Write Path<BR> If (objFSO.FileExists(Path) = True) Then<BR> IsFileExists = True<BR> response.write ("&#060;li&#062;&#060;a href=""/depconweb/"&fname&"/"&FileName&".pdf""&#062;"&FileName&"&#060;/a&#062; ("&fmo&"-"&fyr&")&#060;/li&#062;")<BR> End If <BR> Next <BR><BR>Set objFSO = Nothing <BR>End Function<BR><BR>This helps me check if individual files exist in a given directory, but I need to check also for duplicates of the files. What sort of logic do I add to this function to do that?<BR><BR>Here are sample naming conventions for the files:<BR><BR>"0403-300-0015-564.pdf" <BR>"0403-300-0015-564_1.pdf" &#039;Duplicate<BR>"0403-300-0015-564_2.pdf" &#039;Duplicate<BR><BR>Some files have duplicates and some don&#039;t and the number of duplicates in unlimited.<BR><BR>Any help appreciated.<BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Don't see any way except...

    ...keeping all the file names (that is, the FileName.pdf part) in an array and searching the array for duplicates.<BR><BR>What about<BR> 0403-300-0015-564.pdf <BR> 0404-300-0015-564_1.pdf <BR>is that considered a duplicate?<BR><BR>Not that it really matters. You&#039;re going to have to write custom comparison logic to account for the "_N" stuff, in any case.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts