title
Products            Buy            Support Forum            Professional            About            Codec Central
 

too lazy to rename .rmj's to .ram

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • norm
    • Dec 2003
    • 2

    too lazy to rename .rmj's to .ram

    for any vb6 folks, here is something i just wrote to change the file extensions .rmj to .ram given a folder. it reads sub folders and so on. all changes written to a text file.



    'begin code:
    '
    'change this in code: "E:\My Music\" to your top folder
    'requires this text file: "c:\dave.txt"


    Option Explicit
    Dim i As Long


    Private Sub Form_Load()

    Dim fso As FileSystemObject
    Set fso = New FileSystemObject
    Dim fldr As Folder
    Set fldr = fso.GetFolder("E:\My Music\")

    ListFiles fldr
    ListSubFolders fldr

    Log "Changes Made: " & i

    End Sub

    Private Sub ListSubFolders(ByRef fldr As Folder)
    Dim Subfldr As Folder

    For Each Subfldr In fldr.SubFolders
    Log Subfldr.Path
    ListFiles Subfldr
    ListSubFolders Subfldr
    Next

    End Sub


    Private Sub ListFiles(ByRef fldr As Folder)
    Dim f As File
    Dim str As String

    For Each f In fldr.Files
    If Right(f.Name, 4) = ".rmj" Then

    Log f.Path

    str = Replace(f.Name, ".rmj", ".ram")
    f.Name = str
    i = i + 1

    Log f.Path

    End If
    Next

    End Sub


    ' Print to immediate window; append log file
    ' May log prior to class instantiation so path
    ' constant used here instead of class property.
    Public Sub Log(ByVal Msg As String)

    On Error Resume Next

    Dim l As Long
    l = FreeFile
    Open "c:\dave.txt" For Append As #l
    Print #l, Now & vbTab & Msg
    Close #l

    End Sub


    'end code:



    'begin sample log file:
    12/28/2003 7:47:45 PM E:\My Music\Alice In Chains
    12/28/2003 7:47:45 PM E:\My Music\Alice In Chains\Dirt
    12/28/2003 7:47:45 PM E:\My Music\Alice In Chains\Dirt\01 - Them Bones.rmj
    12/28/2003 7:47:45 PM E:\My Music\Alice In Chains\Dirt\01 - Them Bones.ram
    12/28/2003 7:47:45 PM E:\My Music\Alice In Chains\Dirt\02 - Dam That River.rmj
    12/28/2003 7:47:45 PM E:\My Music\Alice In Chains\Dirt\02 - Dam That River.ram
Working...

]]>