Results 1 to 8 of 8

Thread: [RESOLVED] Renaming files based on age

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    4

    Resolved [RESOLVED] Renaming files based on age

    I have a machine that saves files using machine information which really is quite random.

    What i want to do is move and rename these files sequentially. I have done that, but my code does not do it based on the time the files were saved and I'm stumped.
    I want to save the files (.prn - text files) as 1.prn, 2.prn, 3.prn etc. based on 1.prn being the first the machine wrote. Right now it seems to be a random order, I have not looked, but maybe alphabetical ...

    I appreciate any help you can give me.

    FC

    Here is what I have (it is a snippet,so some variables will not make sense here):
    vb Code:
    1. spath = "c:\program files\outputprn\"
    2. spattern = "*.prn"
    3.  
    4. Set cFiles = New Collection
    5.  
    6. 'get the files to be renamed
    7. sFile = Dir$(spath & spattern)
    8. Do While Len(sFile) > 0
    9.      If (sFile <> "." And sFile <> "..") Then
    10.          cFiles.Add sFile
    11.      End If
    12. sFile = Dir$()
    13. Loop
    14.  
    15. 'rename the files
    16. For iFile = 1 To cFiles.Count
    17.      Name spath & cFiles.Item(iFile) As newpath & Format$(cFiles.Item(iFile), "0")
    18. Next iFile
    Last edited by Hack; Jul 22nd, 2011 at 11:15 AM. Reason: Added Highlight Tags And Some Indenting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width