Rename and move files to a new location

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
8,879
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
8,879
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
8,879
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
8,879
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
8,879
Office Version
2007
Platform
Windows
Again with pleasure. Have a nice day! ;)
 

Forum statistics

Threads
1,082,243
Messages
5,363,972
Members
400,772
Latest member
solbebe

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top