+ Reply to Thread
Results 1 to 5 of 5

Identify identical files names w/ different url paths

Hybrid View

sc0tt Identify identical files... 06-24-2008, 04:21 AM
Rick_Stanich This will strip the names out... 06-24-2008, 05:37 PM
sc0tt Thanks! 06-24-2008, 05:57 PM
Leith Ross Hello Scott and Rick, Here... 06-24-2008, 06:03 PM
Rick_Stanich Thats cool Leith! ;) Using... 06-25-2008, 10:18 AM
  1. #1
    Registered User
    Join Date
    06-12-2008
    Posts
    14

    Exclamation Identify identical files names w/ different url paths

    A1: http://mydomain.com/images/prod01/9006.JPG
    A2: http://mydomain.com/images/prod02/9006.JPG
    A3: http://mydomain.com/images/prod03/9006.JPG
    A4: http://mydomain.com/images/prod03/9007.JPG

    I have a CSV import file that has a column for images. I need to identify identical file names even though the url paths are different. They will all go to a root dir on my server, so I need an excel formulas that will find identical files names in the different cells.

    What I'd like is a formula in Column B, that lists the identical files like this.
    B1: 9006.JPG
    B2: 9006.JPG
    B3: 9006.JPG
    B4: empty cell ""

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,179
    This will strip the names out of the path strings.
    Sub StripFileName()
        With Sheets(1)
            rSh1LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
            Set rSh1Range = .Range("A1:A" & rSh1LastRow)
        End With
        For Each rSh1Cell In rSh1Range    'read from sheet(1)
            If Right(rSh1Cell.Value, 3) = "JPG" Then '*** Asterisks mark lines that can be _
            removed/edited if not specifying JPG files
            'recognition to: Author Merjet from microsoft.public.excel.programming
                For vCt = Len(rSh1Cell) To 1 Step -1
                    If Mid(rSh1Cell, vCt, 1) = "/" Then
                        rSh1Cell.Offset(0, 1).Value = Mid(rSh1Cell, vCt + 1, 20)
                        Exit For
                    End If
                Next vCt
            End If '***
        Next rSh1Cell
    End Sub
    I am still working on removing NON-duplicates as you stated. Perhaps this will get you or some else started. I will get back on this when I can.
    Regards

    Rick
    Win10, Office 365

  3. #3
    Registered User
    Join Date
    06-12-2008
    Posts
    14

    Thanks!

    It's super cool how helpful everyone is!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Scott and Rick,

    Here is another way to get the file name using a UDF (User Defined Funtion). This is a macro that works like a Formula.
    Example
      A1: http://mydomain.com/images/prod01/9006.JPG
      B1: =GetFileName(A1)
    
      B1 result is: 9006.jpg
    Function GetFileName(ByVal File_Path As String) As String
    
      Dim FSO As Object
      
        Set FSO = CreateObject("Scripting.FileSystemObject")
        GetFileName = FSO.GetFileName(File_Path)
       
      Set FSO = Nothing
      
    End Function
    This should make the job easier.

    Sincerely,.
    Leith Ross

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,179
    Thats cool Leith!
    Using your function I modded my original code to this.
    Sub StripFileNameUDF()    'User Defined Function to read file name from a string
    
        With Sheets(1)
            rSh1LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
            Set rSh1Range = .Range("A1:A" & rSh1LastRow)
        End With
        For Each rSh1Cell In rSh1Range    'read from sheet(1)
            If Right(rSh1Cell.Value, 3) = "JPG" Then    '*** Asterisks mark lines that can be _
                                                        removed/edited if not specifying JPG files
                x = GetFileName(Sheets(1).Range(rSh1Cell.Address))
                rSh1Cell.Offset(0, 1).Value = x
                'MsgBox x 'for testing
            End If    '***
        Next rSh1Cell
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1