Results 1 to 2 of 2

Thread: Renaming a file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Location
    Florida, USA
    Posts
    93

    Renaming a file

    Is there any simple way to copy a file, and if that file exists in the target rename it with a consecutive number:
    example:
    File.doc is copied to f:\folders\ then File.doc exists in f:\Folders
    then this file should be renamed it to File(1).doc and if is copied again should be File(3).doc and soo on....
    HELP

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    To see if file exists:

    VB Code:
    1. Public Function FileExists(strFileName As String) As Boolean
    2.   Dim intLen As Integer
    3.   If strFileName$ <> "" Then
    4.     intLen% = Len(Dir$(strFileName$))
    5.     FileExists = (Not Err And intLen% > 0)
    6.   Else
    7.     FileExists = False
    8.   End If
    9. End Function
    My evil laugh has a squeak in it.

    kristopherwilson.com

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