468,146 Members | 1,411 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,146 developers. It's quick & easy.

Renaming thousands of pdf files with different filenames

1
I have thousands of pdf files in one folder and I need to rename it all. EXAMPLE, Filenames should be like this B100000_AICOR_20180209,B100001_AICOR_20180209, B100002_AICOR_20180209, B100003_AICOR_20180209.............what is the easiest way to rename all of this file?
THANKS!
Feb 9 '18 #1
1 2506
SioSio
238 128KB
Expand|Select|Wrap|Line Numbers
  1.         Dim Folder As String = "C:\Folder\"
  2.         Dim files As String() = System.IO.Directory.GetFiles(Folder, "*.pdf", System.IO.SearchOption.AllDirectories)
  3.         Dim Filename As String
  4.         Dim NewFilename As String
  5.         Dim i As Long = 0
  6.         For Each Filename In files
  7.             NewFilename = "B1" & i.ToString("00000") & "_AICOR_20180209" & ".pdf"
  8.             If Not System.IO.File.Exists(Folder & NewFilename) Then
  9.                 System.IO.File.Move(Filename, Folder & NewFilename)
  10.                 i = i + 1
  11.             End If
  12.         Next
  13.  
Dec 20 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Robizzle | last post: by
1 post views Thread by Jaymac | last post: by
2 posts views Thread by rotaryfreak | last post: by
30 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.