Move files to new folder as per list in excel

atuljadhavnetafim

Active Member
Joined
Apr 7, 2012
Messages
341
Office Version
  1. 365
Platform
  1. Windows
Dear Expert

I have 2000+ PDF files in one folder "Current Location" now I want to move this in 3 folders which mentioned in "Desired Location".
i need to copy pdf files to desired location, the original should be in current location as it is.

can any one provide macro for that

File NameCurrent LocationDesired Location
BNCPK8159E_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\SBU SOUTH\
ADUPP6015B_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\HEAD OFFICE\
AWVPS9707M_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\HEAD OFFICE\
ARCPS3364A_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\Chennai-Factory\
ABGPD3118D_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\HEAD OFFICE\
AAGFH7457J_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\HEAD OFFICE\
ADWPV3973C_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\HEAD OFFICE\
ALWPM6372J_Q4_2020-21.pdfC:\Users\ni****p\Desktop\TDS Certificate AllC:\Users\ni****p\Desktop\TDS Certificate All\SBU SOUTH\

Thanks in advance.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Enable microsoft scripting runtime in references.
Code is untested

VBA Code:
Sub bye()
        
        Dim FSO As New FileSystemObject
        Dim des, sour As String
        Dim k As Integer
        Dim lr As Long
        lr = Range("A1").End(xlDown).Row
        
        For k = 2 To lr
                sour = Range("B" & k) & "\" & Range("A" & k)
                des = Range("C" & k)
                FSO.CopyFile sour, des
       Next k
       
        
        
End Sub
 
Upvote 0
Hi,

below error show

1672977530989.png
 
Upvote 0
In column A there's no extension for the filename. If it still doesn't work then there's some permission conflict. Are you the admin of the PC?
Try this code now.


VBA Code:
Sub bye()
        
        Dim FSO As object
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Dim des, sour As String
        Dim k As Integer
        Dim lr As Long
        lr = Range("A1").End(xlDown).Row
        
        For k = 2 To lr
                sour = Range("B" & k) & "\" & Range("A" & k)
                des = Range("C" & k) & "\"
                FSO.CopyFile sour, des
       Next k
       
        
        
End Sub
 
Upvote 0
Solution
Yes, thanks, it's working,
i update file extension and use new code and it's working fine

Thanks a lot, it's save lot's of time.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,953
Members
449,095
Latest member
nmaske

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