SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
ASP.NET, VB.NET, Microsoft .NET Framework, Microsoft Visual Studio, Windows Forms, Controls and more Tutorials and Articles for Programmers


VB.NET File Rename - Rename File Extensions of Multiple Files from .CBR Files to .RAR Files


This VB.NET tutorial with sample VB.NET project will display how developers can code to rename a file extension and rename multiple files on a hard disk using VB.NET codes.

I have a huge list of comic books downloaded in .CBR files extension format.
Since .CBR file type is actually means archived .RAR comic book file type, I wanted to code a VB.NET application to rename multiple files.
My requirement is to rename files in VB.NET from .CBR files extension to .RAR files extension as a batch file renaming process.

My VB.NET file rename software will take the folder path as an input argument.
After the path is identified, the file renaming application will store all the files with .CBR file extension in a VB.NET array.
Then the renaming files will be managed in a VB.NET For Each loop.
Each time looping in the array of selected files, the program will rename file extension from .cbr to .rar file extension.

VB.NET file rename batch file renaming application

And the VB.NET file rename application form design is as follows...

VB.Net file rename multiple files application design





VB.NET File Rename Code


Here is the code in VB.NET to rename files in a given folder path.
You can use the below VB.NET application to rename multiple files with .cbr file extension to a file name with .rar file extension.

Dim files As String()
files = IO.Directory.GetFiles(TextBox1.Text, "*.cbr")
Dim filepath_new As String

For Each filepath As String In files
  filepath_new = filepath.Replace(".cbr", ".rar")
  System.IO.File.Move(filepath, filepath_new)
Next
Sample VB.NET Code

As you will see in the above VB.NET code renaming a file can be easily managed by using .NET Framework method File.Move() in System.IO namespace.
This simple file renamer VB.NET code block can be used in a For Each loop as you see in the same VB code example, for batch file renaming or rename multiple files in a file folder.



Visual Studio


Copyright © 2004 - 2024 Eralper YILMAZ. All rights reserved.