I'm stuck with batch file rename

Discussion in 'General Chat' started by mightyb, Mar 25, 2008.

  1. #1
    I have 5000 files in the folder. I have a text file with 5000 names, one on each line. How can i mass rename these files so that each file gets a name from each line?

    This has been a pain in the back for me. None of the software i tried can do it and there are thousands of renaming applications out there! Any suggestions? Thank you!
     
    mightyb, Mar 25, 2008 IP
  2. flippers.be

    flippers.be Peon

    Messages:
    432
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    learn how to program and make a program yourself that does this..
     
    flippers.be, Mar 26, 2008 IP
  3. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #3
    Get some nerd in the PHP forum to make you something :p
     
    Kerosene, Mar 26, 2008 IP
  4. mythbuster08

    mythbuster08 Peon

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    files on linux server or on windows desktop pc?
    if desktop, simple VB code
    
    Private Function RenameFolderFromFile(ByVal fldname As String, ByVal filname As String) As Boolean
    
            Dim s As String = ""
    
            Try
                Dim freader As New System.IO.StreamReader(filname)
                For Each fld As System.IO.FileInfo In My.Computer.FileSystem.GetDirectoryInfo(fldname).GetFiles
                    If freader.EndOfStream Then
                        MsgBox("Not enough filenames in renamefile")
                        Exit For
                    Else
                        s = freader.ReadLine
                    End If
                    My.Computer.FileSystem.RenameFile(fld.FullName, s)
                Next
                freader.Close()
            Catch ex As Exception
                Return False
            End Try
            Return True
    
        End Function
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            RenameFolderFromFile("c:\fold", "c:\rename.txt")
        End Sub
    
    Code (markup):
    if linux server do the same with php/perl/bash
     
    mythbuster08, Mar 26, 2008 IP
    mightyb likes this.
  5. mightyb

    mightyb Banned

    Messages:
    6,566
    Likes Received:
    405
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well you are helpful!

    mythbuster08

    Legend! I will give it a try now. Thanks!
     
    mightyb, Mar 26, 2008 IP