Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    checking for duplicates (2003)

    Hi everyone

    I am using the below code but it doesn't quite work. The problem is that 'strDocName' and 'strNewDocName' are the same source
    If I try 'If UCase(strSource & strDocName) = UCase(strTraget & strSubfolder & strNewDocName) And _' it reports 'false' as its comparing the directory and the filename.

    How do I make it look at the source file and the duplicate file in the 'strTarget' and ignore there directorys.

    Many thanks

    If UCase(strDocName) = UCase(strNewDocName) And _
    FileLen(strDocName) = FileLen(strNewDocName) And _
    FileDateTime(strDocName) = FileDateTime(strDocName) Then
    Kill (strSource(intLoop2) & strDocName)
    Else
    GoTo Append
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: checking for duplicates (2003)

    Hi Kevin,

    I take it that 'strSource', 'strTarget' and 'strSubfolder' are filepaths. In that case, unless 'UCase(strSource)' = 'UCase(strTarget' & 'strSubfolder)', the results of the comparison must be false, even if 'UCase(strDocName)' = 'UCase(strNewDocName)'.

    Given the above, I don't understand your question:
    <hr>How do I make it look at the source file and the duplicate file in the 'strTarget' and ignore their directories.<hr>
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: checking for duplicates (2003)

    I see strSource and strSource(intLoop2)

    Is strSource a string or an arrray of strings?

  4. #4
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: checking for duplicates (2003)

    I have strSource() as an array,

    Loop 2 is how I recal the strSource() number I set in the code above.

    Example

    If I select 2 folders as source it will set strsource as strSoucre(1) and strSource(2)

    If Loop2 is set to 2 it will retrieve the directory I selected at strSource(2)
    Regards
    Gerbil (AKA Kevin)

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: checking for duplicates (2003)

    Try

    If UCase(strDocName) = UCase(strNewDocName) And _
    FileLen(strSource(intLoop2) & strDocName) = FileLen(strTarget & strSubfolder & strNewDocName) And _
    FileDateTime(strSource(intLoop2) & strDocName) = FileDateTime(strTarget & strSubfolder & strNewDocName) Then
    Kill (strSource(intLoop2) & strDocName)
    Else
    GoTo Append

    In the name comparison, only the file names are used, but in the filesize and date/time comparisons, the full path is used.

  6. #6
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: checking for duplicates (2003)

    Paul, Thanks for your reply.

    strSource is an array and is a maximum of 11 directorys.
    strTarget is the target directory where the file will be moved to or appended to exsiting.
    strSubDirectory is the sub target loaction an is the first 2 numbers of the filename to be moved.

    The script selects the next file in a source directory and trys to find a matching file in the target directory, what I am trying to do is...

    If the script finds a matching filename I want it to check the filename, size, and modifed date if all are TRUE then delete the source and move on to next, if its FALSE then append to target file.

    The rest of the script works. But I can't get the duplicate bit to work because

    strNewDocName = strDoc Name

    The part UCase(strSource) = is fine
    But I dont now how to get it to check the target file because the only way I can get it to look at the correct file in the target directory is to use strTraget & strSubDirectory & strNewDocName
    this always returns false as the directory is included as part of the file name.

    For example

    If I had used

    Dim strCheckDuplicate as String

    strCheckDuplicate = ?????????????

    UCase(strSource) = UCase(strCheckDuplicate)

    How do I make strCheckDuplicate only to check the file itself and ignore the directory.

    Many thanks
    Regards
    Gerbil (AKA Kevin)

  7. #7
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: checking for duplicates (2003)

    Thanks Hans I think I understand now
    Regards
    Gerbil (AKA Kevin)

Posting Permissions

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