Hello Everyone,
I am trying to copy/rename .jpg files where the name of each file is comprised of 5 columns "concatenated". So far, I am able to extract one column, copy/rename old file into a new directory. If you can please help me concatenate columns B through E separated by hyphens (-), I would greatly appreciate it.
Below is code I am currently using and I've attached an image of the excel file I am extracting the info from:
Capture.JPG
'Copies/Renames files from column B. Name needs to be formed from columns B through E
Option Explicit
Sub CopyRenameFile()
Dim src As String, dst As String, fl As String
Dim rfl As String
Dim lngMyRow As Long
Dim lngLastRow As Long
Application.ScreenUpdating = False
lngLastRow = Range("A:B").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row + 1
'Source directory
src = "J:\My Art Work\UncategorizedArtWork\TitledArtWork"
'Destination directory
dst = "C:\Users\felizm\Desktop\temp"
For lngMyRow = 2 To lngLastRow
'File Name
fl = Range("A" & lngMyRow)
'Rename File
rfl = Range("B" & lngMyRow)
On Error Resume Next
FileCopy src & "\" & fl, dst & "\" & rfl & ".jpg"
'If Err.Number <> 0 Then
'MsgBox "Copy Error:" & src & "\" & rfl
'End If
On Error GoTo 0
Next lngMyRow
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
Bookmarks