Moving PDF files

Senthil Murugan

New Member
Joined
Sep 25, 2024
Messages
38
Office Version
  1. 365
Platform
  1. Windows
Good Afternoon to All

Can anybody know how to move PDF files from one folder to another based on PDF file's Partial Name using "*"

Thanks in advance
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You provide very little information, so you will have to adapt the macro to your needs.
At the end of the post I put the notes so you can adapt the macro. 🧙‍♂️

Rich (BB code):
Sub movePDFfiles()
  Dim Folder1 As String, Folder2 As String, sFile As String
  
  Folder1 = "C:\Trabajo\Files\"       'origin
  Folder2 = "C:\trabajo\examples\"    'destination
  
  sFile = Dir(Folder1 & "*.pdf")
  
  Do While sFile <> ""
    If sFile Like "invoice" & "*" Then
      Name Folder1 & sFile As Folder2 & sFile
    End If
    sFile = Dir()
  Loop
  
End Sub

Notes:
  • Change folder1 and folder2 to the names of your folders.
  • Change "invoice" to the partial text you want to search for
  • You can choose where to search for the partial text:
    • "invoice" & "*" : means at the beginning of the name
    • "*" & "invoice" & "*" : means anywhere in the name
    • "*" & "invoice" : means at the end of the name
----- --
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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