Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. rename file

rename file

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
3 Posts 2 Posters 15 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I would like rename a file to the current date.Any idea on how to do this? The file is text file. Thank You,

    J 1 Reply Last reply
    0
    • L Lost User

      I would like rename a file to the current date.Any idea on how to do this? The file is text file. Thank You,

      J Offline
      J Offline
      Jason Gerard
      wrote on last edited by
      #2

      The following code uses the Scripting.FileSystemObject to rename the file specified in strFilePath to the format out mm-dd-yyyy.txt . Ex. for today, the file would be named 04-23-2001.txt Hope this helps Dim strFilePath As String Dim strNewFileName As String Dim fso As FileSystemObject Dim file As File strFilePath = "c:\myText.txt" strNewFileName = Format(Now(), "mm-dd-yyyy") & ".txt" Set fso = New FileSystemObject Set file = fso.GetFile(strFilePath) file.Name = strNewFileName Set file = Nothing Set fso = Nothing Jason Gerard MCSD, MCSE Technology Point International, Inc.

      L 1 Reply Last reply
      0
      • J Jason Gerard

        The following code uses the Scripting.FileSystemObject to rename the file specified in strFilePath to the format out mm-dd-yyyy.txt . Ex. for today, the file would be named 04-23-2001.txt Hope this helps Dim strFilePath As String Dim strNewFileName As String Dim fso As FileSystemObject Dim file As File strFilePath = "c:\myText.txt" strNewFileName = Format(Now(), "mm-dd-yyyy") & ".txt" Set fso = New FileSystemObject Set file = fso.GetFile(strFilePath) file.Name = strNewFileName Set file = Nothing Set fso = Nothing Jason Gerard MCSD, MCSE Technology Point International, Inc.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I need that in VBScript.I think Vbscript doesn't support file.name I am not sure about this.Please let me know.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups