Results 1 to 6 of 6

Thread: In Visual Basic 6.0, How to mass rename file000x.jpg to filex.jpg?

  1. #1
    Join Date
    Aug 2006
    Posts
    121

    In Visual Basic 6.0, How to mass rename file000x.jpg to filex.jpg?

    I am making an application that shows frame one after another just like a movie clip. I am making this application using a Visual Basic 6.0. Every 0.0555 seconds it shows 'frame1.jpg', then after 0.0555 it shows another frame that will be 'frame2.jpg' and keeps on going in this manner. But the program that I save all my frames with saved them as 'frame0001.jpg', 'frame0002.jpg', etc. I cannot manually rename all the files since there are more than 500 frames. So my question is there any way to rename file000x.jpg to filex.jpg, in VB ?? If anyone knowing the easier way please help me..!!
    Whats my name again? I spend so much time looking at code i fogot my own name ahhh!

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: In Visual Basic 6.0, How to mass rename file000x.jpg to filex.jpg?

    I would like to suggest you to repeat the replacing of "frame0" by "frame" in the name after you make a loop in your base folder. You can use the FileSystemObject, since you are using a Visual Basic 6.0 in the following way :
    Dim oFSO as new FileSystemObject
    Dim oFld as Folder, oFile as File

    set oFld = oFSO.getFolder(_the_location_of_your_folder) 'This folder has to exists otherwise there will be an error

    for each oFile in oFld.Files
    while left(oFile.Name, 6) = "frame0"
    oFile.Name = replace(oFile.Name, "frame0", "frame")
    wend
    next
    Now, according to me it should work properly for renaming the mass files. Though I have not checked it personally, but that seems to be OK. I would like to tell you that try this on another location and copy/paste a subset of your frame files before.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: In Visual Basic 6.0, How to mass rename file000x.jpg to filex.jpg?

    I know the program that finds all the normal files in a directory and renames them, replacing one string with another. It uses Replace to replace occurrences of a string with another in the file name after using Dir$ to list the files. It is not renamed, if the file's name doesn't contain the target string. Here is the coding for that :

    Private Sub cmdGo_Click()
    Dim i As Integer
    Dim from_str As String
    Dim dir_path As String
    Dim to_str As String
    Dim new_name As String
    Dim old_name As String

    On Error GoTo RenameError

    from_str = txtFromString.Text
    to_str = txtToString.Text

    dir_path = txtDirectory.Text
    If Right$(dir_path, 1) <> "\" Then dir_path = dir_path _
    & "\"

    old_name = Dir$(dir_path & "*.*", vbNormal)
    Do While Len(old_name) > 0
    ' Rename this file.
    new_name = Replace$(old_name, from_str, to_str)
    If new_name <> old_name Then
    Name dir_path & old_name _
    As dir_path & new_name
    i = i + 1
    End If

    ' Get the next file.
    old_name = Dir$()
    Loop

    MsgBox "Renamed " & Format$(i) & " files."
    Exit Sub

    RenameError:
    MsgBox Err.Description
    End Sub

    Hope that this program will help you.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: In Visual Basic 6.0, How to mass rename file000x.jpg to filex.jpg?

    A new StdPicture object is created and loaded with a JPG file in Visual Basic. A new cDIBSection object is created and the same JPG file is loaded for the IJL library, and here is coding for that :

    Private Sub cmdVB_Click()
    Dim fT As Double
    Dim picThis As New StdPicture
    fT = Timer
    Set picThis = LoadPicture(App.Path & "\photo.jpg")
    Debug.Print "Time:", Timer - fT
    End Sub

    This code will help you to load the images in the VB.

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    Re: In Visual Basic 6.0, How to mass rename file000x.jpg to filex.jpg?

    I have tried to make little change in the coding that 'Modifier' has mentioned. The following is the Code :

    for each dim oFile in new FileSystemObject.getFolder(_the_location_of_your_folder).Files
    while left(oFile.Name, 6) = "frame0"
    oFile.Name = replace(oFile.Name, "frame0", "frame")
    wend
    next

    I think that you will able to rename the mass files that you wanted.

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: In Visual Basic 6.0, How to mass rename file000x.jpg to filex.jpg?

    I think that the program that you were looking for might have got to you in above answers. I am providing an alternate script using biterscripting :

    # The files that you want to rename, you should go to that directory.
    cd "C:/somefolder"
    # Then you have to get the list of the files.
    var str list; lf -n "frame*" > $list
    # The following variable is used to store the file count.
    var int count
    # Go thru files one by one.
    while ($list <> "")
    do
    # Get the next file
    var str file; lex "1" $list > $file
    # Increment count.
    set $count = $count + 1
    # New name is "frame"+$count+".jpg" . Rename file.
    system rename ("\""+$file+"\"") ("frame"+makestr(int($count))+".jpg")
    done

Similar Threads

  1. Visual C# 2008, How to mass rename files
    By rickymccall in forum Software Development
    Replies: 6
    Last Post: 17-07-2010, 06:26 PM
  2. Dos mass rename with Net Tools
    By Vishal Singh in forum Windows Software
    Replies: 1
    Last Post: 22-06-2009, 01:42 PM
  3. Rename mass files Titles in mac os
    By Cody in forum Operating Systems
    Replies: 4
    Last Post: 21-04-2009, 02:24 PM
  4. Is GUI same like Visual Basic ?
    By Caesar in forum Software Development
    Replies: 2
    Last Post: 02-03-2009, 01:32 PM
  5. Visual Basic 2005 or Visual Basic 6
    By Aasha in forum Software Development
    Replies: 5
    Last Post: 15-01-2009, 06:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,716,700,028.74195 seconds with 16 queries