Results 1 to 5 of 5
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: rename and move new file .. (2000)

    Sub Movem()
    Const strOldPath = "C:my_dir"
    Const strNewPath = "C:servizio"
    Dim strOldName As String
    Dim strNewName
    strOldName = Dir(strOldPath & "*.xls")
    Do While Not strOldName = ""
    strNewName = Left(strOldName, Len(strOldName) - 13) & ".xls"
    Name strOldPath & strOldName As strNewPath & strNewName
    strOldName = Dir
    Loop
    End Sub

    How about the replies to <post#=710,536>post 710,536</post#> and <post#=710,730>post 710,730</post#>?

  2. #2
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: rename and move new file .. (2000)

    ahhhhhhhhhhhh.... is possible to overwrite the old file, with the same name, if existis without pop....

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: rename and move new file .. (2000)

    Try this version:

    Sub Movem()
    Const strOldPath = "C:my_dir"
    Const strNewPath = "C:servizio"
    Dim strOldName As String
    Dim strNewName As String

    On Error GoTo ErrHandler

    strOldName = Dir(strOldPath & "*.xls")
    Do While Not strOldName = ""
    strNewName = Left(strOldName, Len(strOldName) - 13) & ".xls"
    Name strOldPath & strOldName As strNewPath & strNewName
    strOldName = Dir
    Loop
    Exit Sub

    ErrHandler:
    If Err = 58 Then
    ' Target file exists, so delete it
    Kill strNewPath & strNewName
    ' And continue
    Resume
    Else
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: rename and move new file .. (2000)

    NO WORDS!!!!
    Tks.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    rename and move new file .. (2000)

    I have this file in c:my_dir and i want to rename all file without the prefix "_date" and copy in new dir named c:servizio...

    from c:my_dirMkt_semianalitico_GG_Business_07052008.xls

    to c:servizioMkt_semianalitico_GG_Business.xls

    repeat for all files

Posting Permissions

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