Hi,

I try to rename a folder and I can't.

on error resume next
dim fso
dim fldr

set fso=createobject("scripting.filesystemObject")
Set fldr = fso.GetFolder("C:\test")
fldr.Name = "C:\test1"

it's not work!

If I put this after the line: fldr.Name = "C:\test1"

if err.number > 0 then
msgbox "error"
end if

the msgbox appear. The name of the folder don't change.

Why doesn't work? an another way to rename a folder?

thank

Dany

Re: rename a folder by Viatcheslav

Viatcheslav
Thu May 27 09:31:19 CDT 2004

You can not move folder into another directory this way, as well as specify
full path.

fldr.Name = "test1"

To move folder into another directory use FileSystemObject.MoveFolder()

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"Dany Marois" <dany_marois@artefact.qc.ca> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:%23ExpE7%23QEHA.252@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I try to rename a folder and I can't.
>
> on error resume next
> dim fso
> dim fldr
>
> set fso=createobject("scripting.filesystemObject")
> Set fldr = fso.GetFolder("C:\test")
> fldr.Name = "C:\test1"
>
> it's not work!
>
> If I put this after the line: fldr.Name = "C:\test1"
>
> if err.number > 0 then
> msgbox "error"
> end if
>
> the msgbox appear. The name of the folder don't change.
>
> Why doesn't work? an another way to rename a folder?
>
> thank
>
> Dany
>
>



Re: rename a folder by tomthumbkop

tomthumbkop
Thu May 27 10:44:16 CDT 2004


Use this:
Option Explicit
Dim oFSO, oFolder

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("C:\Test")
oFolder.Copy "C:\test1", True
oFolder.Delete True
Set oFolder = Nothing
Set oFSO = Nothing

Dany Marois wrote:
> *Hi,
>
> I try to rename a folder and I can't.
>
> on error resume next
> dim fso
> dim fldr
>
> set fso=createobject("scripting.filesystemObject")
> Set fldr = fso.GetFolder("C:\test")
> fldr.Name = "C:\test1"
>
> it's not work!
>
> If I put this after the line: fldr.Name = "C:\test1"
>
> if err.number > 0 then
> msgbox "error"
> end if
>
> the msgbox appear. The name of the folder don't change.
>
> Why doesn't work? an another way to rename a folder?
>
> thank
>
> Dany


-
tomthumbko
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------


Re: rename a folder by Fosco

Fosco
Sun May 30 22:31:29 CDT 2004

"Dany Marois"

sDay=Day(Date) :sMonth=Month(Date) :sYear=Year(Date)
s = sDay&"-"&sMonth&"-"&sYear
Set fso = CreateObject("Scripting.FileSystemObject")
sTarget="C:\test"
sRen="RENAMED"
set oRen= fso.GetFolder(sTarget)
sTemp = sRen & " "& s
oRen.Name = sTemp
--
Fosco