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 Kodyaz Development Resources
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.






.NET Framework, ASP.NET

ASP.NET, Windows Forms, Controls, .NET Framework and Visual Studio Articles

ASP.NET Forums

Visual Studio Forums

.NET Development Blog

Certification Exams Blog




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

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.












Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems