We help IT Professionals succeed at work.

rename file based on textbox contents

Judson Hall
Judson Hall asked
on
Medium Priority
1,180 Views
Last Modified: 2012-05-05
I'm attempting to write a VB.Net program that renames a .mov file based on user entries in a series of textboxes.   i.e. Box1 = dog.mov,  Box2 = lp124,  Box3 = tues with a desired output of a file rename as lp123_tues.mov

I have 10 rows of 3 columns so that I can process 10 different files at once.

Any help would be greatly appriciated.
Comment
Watch Question

Commented:
Dim oldfilename As String
dim newfilename as string
newfilename=box2.text & "_" & box3.text & microsoft.visualbasic.right(box1.text,4)

My.Computer.FileSystem.RenameFile(oldfilename, newfilename)

' or microsoft.visualbasic.filesystem.rename oldfilename, newfilename
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
I think it is:

Dim filenamepath As String = YourFilePath ' (you can get this using System.IO namespace)
Dim oldfilename As String = filenamepath & "\" & Box1.Text
dim newfilename as string = filenamepath  & "\" & Box2.Text & "_" & Box3.Text & ".mov"

My.Computer.FileSystem.RenameFile(oldfilename, newfilename)
Judson HallSystems Admin

Author

Commented:
Getting closer .... Attached is the code I have so far and a gif of the interface I'm working with ... of course I'll have to start a thread that will step through the additional rows (i.e. orig1.text, orig2.text, orig3.text and the associated textboxes.


Thanks for the assistance
Imports System.IO
 
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        If FolderBrowserDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
            Label1.Text = FolderBrowserDialog.SelectedPath
 
        End If
 
    End Sub
 
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
 
        Dim filenamepath As String = Label1.Text ' (you can get this using System.IO namespace)
        Dim oldfilename As String = filenamepath & "\" & Orig1.Text
        Dim newfilename As String = filenamepath & "\" & HouseNum1.Text & "_" & ISCI1.Text & "_" & Length1.Text & "_" & Title1.Text & ".mov"
 
        Microsoft.VisualBasic.FileSystem.Rename(oldfilename, newfilename)
 
    End Sub
 
End Class

Open in new window

avidconvert.gif
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
What are the problem now ?

Another thing ... why don't you use a listview or datagridview for that ?
Judson HallSystems Admin

Author

Commented:
Thanks guys! I'll post another question about datagridview and list view .

Explore More ContentExplore courses, solutions, and other research materials related to this topic.