Renaming a file

  • how can we move files

  • Copyfile method is for moving files but keeping their original name.

    Look into Copy method. See link:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/c98c7d8c-ba9e-46b7-bc29-14ab1b7f06f3.asp


    ------------------------------
    The Users are always right - when I'm not wrong!

  • thanks for the help.

    But this does the same thing I do. I need to append the system date to the file after I copy or move it.

  • I think the problem is that you are trying to create an extension - .dash26/01/06.

    Slashes are not allowed in filenames. Try formatting the date to remove slashes, dots etc...


    ------------------------------
    The Users are always right - when I'm not wrong!

  • sDestinationFile = "C:\activant\bkup\test.dash" & "-" & Year & Right( "0" & Month(Now), 2) & Right( "0" & Day(Now), 2)

    This would give you the following result

    test.dash-20060222

    -Mike Gercevich

  • strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _

        & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

    Set colFiles = objWMIService.ExecQuery _

        ("Select * from Cim_Datafile where Name = " _

            & "'f:\\Backups\\NombreArchivoARenombrar.bkf'")

    dim nombre

    nombre = datepart("yyyy",now()) & datepart("m",now()) & datepart("d",now())

    strDate = cstr(date())

    For Each objFile in colFiles

        errResult = objFile.Rename("f:\\Backups\\" & nombre & ".bkf")

    Next

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply