• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1166
  • Last Modified:

rename file based on textbox contents

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.
0
Judson Hall
Asked:
Judson Hall
  • 2
  • 2
2 Solutions
 
vb_jonasCommented:
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
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
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)
0
 
Judson HallSystems AdminAuthor 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
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
What are the problem now ?

Another thing ... why don't you use a listview or datagridview for that ?
0
 
Judson HallSystems AdminAuthor Commented:
Thanks guys! I'll post another question about datagridview and list view .
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now