Visual Basic - Copiar un archivo con diferentes nombres

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Copiar un archivo con diferentes nombres

Publicado por Pedro Sergio (1 intervención) el 23/06/2015 00:43:16
Hola soy principiante en visual basic

Hola quiero saber como hacer una aplicacion sencilla que seleccione una archivo y lo renombre con un nombre especifico y solo cambiando la numeracion por ejemplo hasta ahora he usado este codigo muy simple...

Module Module1

Sub Main()

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\È­ÀÌÆ®½º¹Ì½º_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°Ç³Ê_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°Ç³Ê_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°Ë»Ç_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°Ë»Ç_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°Ë»ÇÆÄÄÚ_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°Ë»ÇÆÄÄÚ_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°ÁÈ¥_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\°ÁÈ¥_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±Ã¼Ö_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±Ã¼Ö_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±Ç¼º_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±Ç¼º_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±×¸®ÆٷξÂ_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±×¸®ÆٷξÂ_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±Â»Ç_³²_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

' Copy the file to a new folder and rename it.
My.Computer.FileSystem.CopyFile(
"C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL",
"C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados\±Â»Ç_¿©_594.pal",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)

End Sub

End Module

Me ha servido mucho pero es muy basico aunque si me ahorra trabajo ya que son mas de 180 archivos nuevos lo que estuve haciendo es con un procesador de texto sustituir la ruta del archivo principal "C:\Users\Roxas\Desktop\arianepalettes\Blanc\B Violet.PAL" y el numero de serie "594"

hay alguna manera mas facil?

me estuve informando de los arrays pero no entiendo bien como trabajan Muchas gracias por su atencion
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Copiar un archivo con diferentes nombres

Publicado por solitario (2 intervenciones) el 25/06/2015 07:35:50
Aqui esta un sencillo programa Pedro Sergio
En un nuevo proyecto inserta :5 textbox,5 labels,un button1
y pega este codigo fuente entre:
Public Class Form1
y
End Class
Dios te bendiga

asi te va a quedar:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Public Class Form1
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim x As Integer
        Dim a As Single
        Dim b As Single
        Dim c As Single
        For x = 1 To TextBox4.Text
            a = Int((90 - 65 + 1) * Rnd() + 65)
            b = Int((90 - 65 + 1) * Rnd() + 65)
            c = Int((90 - 65 + 1) * Rnd() + 65)
            My.Computer.FileSystem.CopyFile(TextBox1.Text & "\" & TextBox2.Text, TextBox5.Text & "\" & a & b & c & "_" & TextBox3.Text & ".pal")
        Next x
        x = x + 1
    End Sub
 
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Label1.Text = "Carpeta de la copia"
        Label2.Text = "Nombre del archivo a renombrar:"
        Label3.Text = "Numero de copias:"
        Label4.Text = "Serie:"
        Label5.Text = "Destino de la copia:"
        TextBox1.Text = "C:\Users\Roxas\Desktop\arianepalettes\Blanc"
        TextBox2.Text = "B Violet.PAL"
        TextBox3.Text = "594"
        TextBox4.Text = "180"
        TextBox5.Text = "C:\Users\Roxas\Desktop\arianepalettes\palettesrenombrados"
        Button1.Text = "Iniciar"
    End Sub
End Class
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar