Rename and move files to a new location

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,674
Office Version
2007
Platform
Windows
No... i am sorry i didn't understand the question
The source folder is a temp folder C:\Users\chma\Desktop\EA

The destination is W:\GR-IPP_II\02. Engineering\ + what is shown in the last column without the PROJECT_483
I am trying to understand.

This file
483-21-DT-M-00300-Ed001.pdf
It is in this folder:
C:\Users\chma\Desktop\EA\


Then you want this:
"Cell E" & "space" & "Rev." & "Cell C" & "space" & "(" & "Cell F" & ")"
483-21-DT-M-00300-Ed001.pdf483-21-DT-M-00300105-12-19111915-21-YDS-MDD-EA-00300P&ID SYMBOLOGY AND GENERAL NOTESPROJECT_483\200 Mechanical Area\221 Systems\221.01 P&IDs

Final name:
111915-21-YDS-MDD-EA-00300
Rev.1 (P&ID SYMBOLOGY AND GENERAL NOTES)

Final folder:
W:\GR-IPP_II\02. Engineering\200 Mechanical Area\221 Systems\221.01 P&IDs\

________________
If not. You could recreate what you need, following my example.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,674
Office Version
2007
Platform
Windows
If the above is correct, then try the following:

VBA Code:
Sub Rename_and_move_files()
  Dim Path1 As String, Path2 As String, Path3 As String
  Dim wNew As String, wOld As String, i As Long
  Dim c1 As String, c2 As String, c3 As String

  Path1 = "C:\Users\chma\Desktop\EA\"         'origin
  Path2 = "W:\GR-IPP_II\02. Engineering"      'destination

  For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
    Path3 = Replace(Range("G" & i), "PROJECT_483", Path2)
    If Right(Path3, 1) <> "\" Then Path3 = Path3 & "\"
    wOld = Range("A" & i).Value
    c1 = IIf(Range("E" & i).Value <> "", Range("E" & i).Value, " - ")
    c2 = IIf(Range("C" & i).Value <> "", Range("C" & i).Value, " - ")
    c3 = IIf(Range("F" & i).Value <> "", Range("F" & i).Value, " - ")
    wNew = c1 & " " & "Rev" & c2 & " " & "(" & c3 & ")" & ".pdf"
    If Dir(Path1 & wOld) <> "" Then
      If Dir(Path3, vbDirectory) <> "" Then
        Name Path1 & wOld As Path3 & wNew
      Else
        MsgBox "Does not exists folder : " & Path3
      End If
    Else
      MsgBox "Does not existe file : " & Path1 & wOld
    End If
  Next
End Sub
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,674
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 

chrysanthi

New Member
Joined
Dec 6, 2019
Messages
12
Office Version
365, 2010
Platform
Windows
i still havent found how to make this thread- solved
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,674
Office Version
2007
Platform
Windows
Don't worry, just write that this thread was solved, or simply with the thanks you sent in post #23 is enough!
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
9,674
Office Version
2007
Platform
Windows
Again with pleasure. Have a nice day! ;)
 

Forum statistics

Threads
1,085,429
Messages
5,383,624
Members
401,843
Latest member
stevensmith1

Some videos you may like

This Week's Hot Topics

Top