Rename and move files to a new location

chrysanthi

New Member
Joined
Dec 6, 2019
Messages
12
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Dear all,
I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following: Column E & ( & column F & ) & Rev & Column C.

Then each one of them must be send to a new folder location which is C:\Users\chma\Desktop\F2 - Copy & Column G (but the word PROJECT_483 must be repplaced by the C:\Users\chma\Desktop\F2 - Copy)

ABCDEFG
FILEDOCUMENT IDENTIFICATIONISSUEDATEKKSTITLEPATH
483-21-DT-M-00300-Ed001.pdf483-21-DT-M-00300
1​
05-12-19​
111915-21-YDS-MDD-EA-00300P&ID SYMBOLOGY AND GENERAL NOTESPROJECT_483\200 Mechanical Area\221 Systems\221.01 P&IDs
483-21-FV-D-00001-Ed001.pdf483-21-FV-D-00001
1​
05-12-19​
Monthly Progress Report (NOVEMBER 2019)PROJECT_483\000 Project Management\001 General\001.03 Progress Reports
483-21-S-M-20250-Ed002.pdf483-21-S-M-20250
2​
04-12-19​
111915-21-PA_-MHP-EA-20250COOLING TOWERS (INDUCED DRAFT) DATA SHEETPROJECT_483\200 Mechanical Area\221 Systems\221.05 Data Sheets


Thank you
 
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.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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
 
Upvote 0
Don't worry, just write that this thread was solved, or simply with the thanks you sent in post #23 is enough!
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top